4.8.9 test fix (#2330)

* perf: query extension prompt

* perf: get preview histories

* perf: i18n

* fix: share page cannot feedback

* fix: publish i18n
This commit is contained in:
Archer
2024-08-12 12:09:14 +08:00
committed by GitHub
parent e098b2f1dc
commit 02d6b7c788
14 changed files with 40 additions and 25 deletions

View File

@@ -94,7 +94,11 @@ export const sliceJsonStr = (str: string) => {
export const sliceStrStartEnd = (str: string, start: number, end: number) => { export const sliceStrStartEnd = (str: string, start: number, end: number) => {
const overSize = str.length > start + end; const overSize = str.length > start + end;
if (!overSize) return str;
const startContent = str.slice(0, start); const startContent = str.slice(0, start);
const endContent = overSize ? str.slice(-end) : ''; const endContent = overSize ? str.slice(-end) : '';
return startContent + (overSize ? ` ...... ` : '') + endContent;
return `${startContent}${overSize ? `\n\n...[hide ${str.length - start - end} chars]...\n\n` : ''}${endContent}`;
}; };

View File

@@ -28,13 +28,15 @@ export const getChatTitleFromChatMessage = (message?: ChatItemType, defaultValue
// Keep the first n and last n characters // Keep the first n and last n characters
export const getHistoryPreview = ( export const getHistoryPreview = (
completeMessages: ChatItemType[] completeMessages: ChatItemType[],
size = 100
): { ): {
obj: `${ChatRoleEnum}`; obj: `${ChatRoleEnum}`;
value: string; value: string;
}[] => { }[] => {
return completeMessages.map((item, i) => { return completeMessages.map((item, i) => {
const n = item.obj === ChatRoleEnum.System || i >= completeMessages.length - 2 ? 80 : 40; const n =
(item.obj === ChatRoleEnum.System && i === 0) || i >= completeMessages.length - 2 ? size : 50;
// Get message text content // Get message text content
const rawText = (() => { const rawText = (() => {
@@ -65,13 +67,9 @@ export const getHistoryPreview = (
return ''; return '';
})(); })();
const startContent = rawText.slice(0, n);
const endContent = rawText.length > 2 * n ? rawText.slice(-n) : '';
const content = startContent + (rawText.length > n ? ` ...... ` : '') + endContent;
return { return {
obj: item.obj, obj: item.obj,
value: sliceStrStartEnd(content, 80, 80) value: sliceStrStartEnd(rawText, n, n)
}; };
}); });
}; };

View File

@@ -11,7 +11,7 @@ import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
*/ */
const defaultPrompt = `作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。生成的问题要求指向对象清晰明确,并与“原问题语言相同”。 const defaultPrompt = `作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。生成的问题要求指向对象清晰明确,并与“原问题语言相同”。
下面的 <Example></Example> 标签对中的示例仅供你学习,请勿在无历史记录的情况下,引用示例中的词 参考 <Example></Example> 标中的示例来完成任务
<Example> <Example>
历史记录: 历史记录:
@@ -92,7 +92,7 @@ A: Laf 是一个云函数开发平台。
</Example> </Example>
---------------- ----------------
我们开始吧! 下面是正式的任务:
历史记录: 历史记录:
""" """

View File

@@ -226,7 +226,7 @@ export const runToolWithFunctionCall = async (
toolName: '', toolName: '',
toolAvatar: '', toolAvatar: '',
params: '', params: '',
response: sliceStrStartEnd(stringToolResponse, 300, 300) response: sliceStrStartEnd(stringToolResponse, 500, 500)
} }
}) })
}); });

View File

@@ -204,7 +204,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
toolCallTokens: totalTokens, toolCallTokens: totalTokens,
model: modelName, model: modelName,
query: userChatInput, query: userChatInput,
historyPreview: getHistoryPreview(GPTMessages2Chats(completeMessages, false)), historyPreview: getHistoryPreview(GPTMessages2Chats(completeMessages, false), 10000),
toolDetail: childToolResponse toolDetail: childToolResponse
}, },
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [ [DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [

View File

@@ -255,7 +255,7 @@ export const runToolWithPromptCall = async (
toolName: '', toolName: '',
toolAvatar: '', toolAvatar: '',
params: '', params: '',
response: sliceStrStartEnd(stringToolResponse, 300, 300) response: sliceStrStartEnd(stringToolResponse, 500, 500)
} }
}) })
}); });

View File

@@ -235,7 +235,7 @@ export const runToolWithToolChoice = async (
toolName: '', toolName: '',
toolAvatar: '', toolAvatar: '',
params: '', params: '',
response: sliceStrStartEnd(stringToolResponse, 300, 300) response: sliceStrStartEnd(stringToolResponse, 500, 500)
} }
}) })
}); });

View File

@@ -221,7 +221,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
tokens, tokens,
query: `${userChatInput}`, query: `${userChatInput}`,
maxToken: max_tokens, maxToken: max_tokens,
historyPreview: getHistoryPreview(chatCompleteMessages), historyPreview: getHistoryPreview(chatCompleteMessages, 10000),
contextTotalLen: completeMessages.length contextTotalLen: completeMessages.length
}, },
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [ [DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [

View File

@@ -1088,7 +1088,8 @@
"Remove InheritPermission Confirm": "This operation will cause to lose the current permission settings, whether to continue?", "Remove InheritPermission Confirm": "This operation will cause to lose the current permission settings, whether to continue?",
"Resume InheritPermission Confirm": "Whether to resume to inherit the parent folder's permission?", "Resume InheritPermission Confirm": "Whether to resume to inherit the parent folder's permission?",
"Resume InheritPermission Failed": "Resume Failed", "Resume InheritPermission Failed": "Resume Failed",
"Resume InheritPermission Success": "Resume Success" "Resume InheritPermission Success": "Resume Success",
"change_owner_tip": "Your permissions will not be retained after transfer"
}, },
"plugin": { "plugin": {
"App": "Select app", "App": "Select app",

View File

@@ -598,8 +598,7 @@
"success": "开始同步" "success": "开始同步"
} }
}, },
"training": { "training": {}
}
}, },
"data": { "data": {
"Auxiliary Data": "辅助数据", "Auxiliary Data": "辅助数据",
@@ -1095,7 +1094,7 @@
"change_owner_failed": "转移所有权失败", "change_owner_failed": "转移所有权失败",
"change_owner_placeholder": "输入用户名查找账号", "change_owner_placeholder": "输入用户名查找账号",
"change_owner_success": "成功转移所有权", "change_owner_success": "成功转移所有权",
"change_owner_tip": "转移后将保留您的管理员权限", "change_owner_tip": "转移后您的权限不会保留",
"change_owner_to": "转移给" "change_owner_to": "转移给"
}, },
"plugin": { "plugin": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "app", "name": "app",
"version": "4.8.8", "version": "4.8.9",
"private": false, "private": false,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -20,11 +20,11 @@ export const workflowBoxStyles: FlexProps = {
export const publishStatusStyle = { export const publishStatusStyle = {
unPublish: { unPublish: {
colorSchema: 'adora' as any, colorSchema: 'adora' as any,
text: i18nT('common:core.app.have_publish') text: i18nT('common:core.app.not_published')
}, },
published: { published: {
colorSchema: 'green' as any, colorSchema: 'green' as any,
text: i18nT('common:core.app.not_published') text: i18nT('common:core.app.have_publish')
} }
}; };

View File

@@ -15,7 +15,6 @@ import PageContainer from '@/components/PageContainer';
import ChatHeader from './components/ChatHeader'; import ChatHeader from './components/ChatHeader';
import ChatHistorySlider from './components/ChatHistorySlider'; import ChatHistorySlider from './components/ChatHistorySlider';
import { serviceSideProps } from '@/web/common/utils/i18n'; import { serviceSideProps } from '@/web/common/utils/i18n';
import { checkChatSupportSelectFileByChatModels } from '@/web/core/chat/utils';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
import { delChatRecordById, getChatHistories, getInitOutLinkChatInfo } from '@/web/core/chat/api'; import { delChatRecordById, getChatHistories, getInitOutLinkChatInfo } from '@/web/core/chat/api';
import { getChatTitleFromChatMessage } from '@fastgpt/global/core/chat/utils'; import { getChatTitleFromChatMessage } from '@fastgpt/global/core/chat/utils';
@@ -97,7 +96,13 @@ const OutLink = ({ appName, appIntro, appAvatar }: Props) => {
} = useChat(); } = useChat();
const startChat = useCallback( const startChat = useCallback(
async ({ messages, controller, generatingMessage, variables }: StartChatFnProps) => { async ({
messages,
controller,
generatingMessage,
variables,
responseChatItemId
}: StartChatFnProps) => {
const completionChatId = chatId || getNanoid(); const completionChatId = chatId || getNanoid();
const histories = messages.slice(-1); const histories = messages.slice(-1);
@@ -119,6 +124,7 @@ const OutLink = ({ appName, appIntro, appAvatar }: Props) => {
...variables, ...variables,
...customVariables ...customVariables
}, },
responseChatItemId,
shareId, shareId,
chatId: completionChatId, chatId: completionChatId,
appType: chatData.app.type, appType: chatData.app.type,

View File

@@ -79,7 +79,13 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
} = useChat(); } = useChat();
const startChat = useCallback( const startChat = useCallback(
async ({ messages, controller, generatingMessage, variables }: StartChatFnProps) => { async ({
messages,
controller,
generatingMessage,
variables,
responseChatItemId
}: StartChatFnProps) => {
const completionChatId = chatId || getNanoid(); const completionChatId = chatId || getNanoid();
// Just send a user prompt // Just send a user prompt
const histories = messages.slice(-1); const histories = messages.slice(-1);
@@ -91,6 +97,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
...variables, ...variables,
...customVariables ...customVariables
}, },
responseChatItemId,
appId, appId,
teamId, teamId,
teamToken, teamToken,