feat: source id prefix env (#3103)
This commit is contained in:
@@ -80,6 +80,7 @@ const pushChatLogInternal = async ({
|
||||
url: string;
|
||||
metadata?: Metadata;
|
||||
}) => {
|
||||
try {
|
||||
const [chatItemHuman, chatItemAi] = await Promise.all([
|
||||
MongoChatItem.findById(chatItemIdHuman).lean(),
|
||||
MongoChatItem.findById(chatItemIdAi).lean() as Promise<AIChatItemType>
|
||||
@@ -112,7 +113,10 @@ const pushChatLogInternal = async ({
|
||||
return;
|
||||
}
|
||||
const responseData = chatItemAi.responseData;
|
||||
const responseTime = responseData?.reduce((acc, item) => acc + (item?.runningTime ?? 0), 0) || 0;
|
||||
const responseTime =
|
||||
responseData?.reduce((acc, item) => acc + (item?.runningTime ?? 0), 0) || 0;
|
||||
|
||||
const sourceIdPrefix = process.env.SOURCE_ID_PREFIX ?? '';
|
||||
|
||||
const chatLog: ChatLog = {
|
||||
title: chat.title,
|
||||
@@ -135,14 +139,17 @@ const pushChatLogInternal = async ({
|
||||
sourceName: chat.source ?? '-',
|
||||
// @ts-ignore
|
||||
createdAt: new Date(chatItemAi.time).getTime(),
|
||||
sourceId: `crbeer-fastgpt-${appId}`
|
||||
sourceId: `${sourceIdPrefix}${appId}`
|
||||
};
|
||||
await axios
|
||||
.post(url + '/api/chat/push', chatLog)
|
||||
.post(`${url}/api/chat/push`, chatLog)
|
||||
.then((res) => {
|
||||
addLog.info('[ChatLogPush] push success', res.data);
|
||||
})
|
||||
.catch((e) => {
|
||||
addLog.error('[ChatLogPush] push failed', { e, resData: e.response?.data });
|
||||
});
|
||||
} catch (e) {
|
||||
addLog.error('[ChatLogPush] error', e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,5 +50,7 @@ WORKFLOW_MAX_LOOP_TIMES=50
|
||||
|
||||
# 对话日志推送服务
|
||||
# URL/INTERVAL 为空时不推送
|
||||
# 前缀用于区分不同的对话日志来源
|
||||
# CHAT_LOG_URL=http://localhost:8080
|
||||
# CHAT_LOG_INTERVAL=10000
|
||||
# SOURCE_ID_PREFIX=fastgpt-
|
||||
|
||||
Reference in New Issue
Block a user