mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
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:
@@ -94,7 +94,11 @@ export const sliceJsonStr = (str: string) => {
|
||||
|
||||
export const sliceStrStartEnd = (str: string, start: number, end: number) => {
|
||||
const overSize = str.length > start + end;
|
||||
|
||||
if (!overSize) return str;
|
||||
|
||||
const startContent = str.slice(0, start);
|
||||
const endContent = overSize ? str.slice(-end) : '';
|
||||
return startContent + (overSize ? ` ...... ` : '') + endContent;
|
||||
|
||||
return `${startContent}${overSize ? `\n\n...[hide ${str.length - start - end} chars]...\n\n` : ''}${endContent}`;
|
||||
};
|
||||
|
@@ -28,13 +28,15 @@ export const getChatTitleFromChatMessage = (message?: ChatItemType, defaultValue
|
||||
|
||||
// Keep the first n and last n characters
|
||||
export const getHistoryPreview = (
|
||||
completeMessages: ChatItemType[]
|
||||
completeMessages: ChatItemType[],
|
||||
size = 100
|
||||
): {
|
||||
obj: `${ChatRoleEnum}`;
|
||||
value: string;
|
||||
}[] => {
|
||||
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
|
||||
const rawText = (() => {
|
||||
@@ -65,13 +67,9 @@ export const getHistoryPreview = (
|
||||
return '';
|
||||
})();
|
||||
|
||||
const startContent = rawText.slice(0, n);
|
||||
const endContent = rawText.length > 2 * n ? rawText.slice(-n) : '';
|
||||
const content = startContent + (rawText.length > n ? ` ...... ` : '') + endContent;
|
||||
|
||||
return {
|
||||
obj: item.obj,
|
||||
value: sliceStrStartEnd(content, 80, 80)
|
||||
value: sliceStrStartEnd(rawText, n, n)
|
||||
};
|
||||
});
|
||||
};
|
||||
|
@@ -11,7 +11,7 @@ import { chatValue2RuntimePrompt } from '@fastgpt/global/core/chat/adapt';
|
||||
*/
|
||||
|
||||
const defaultPrompt = `作为一个向量检索助手,你的任务是结合历史记录,从不同角度,为“原问题”生成个不同版本的“检索词”,从而提高向量检索的语义丰富度,提高向量检索的精度。生成的问题要求指向对象清晰明确,并与“原问题语言相同”。
|
||||
下面的 <Example></Example> 标签对中的示例仅供你学习,请勿在无历史记录的情况下,引用示例中的词。
|
||||
参考 <Example></Example> 标中的示例来完成任务。
|
||||
|
||||
<Example>
|
||||
历史记录:
|
||||
@@ -92,7 +92,7 @@ A: Laf 是一个云函数开发平台。
|
||||
</Example>
|
||||
|
||||
----------------
|
||||
我们开始吧!
|
||||
下面是正式的任务:
|
||||
|
||||
历史记录:
|
||||
"""
|
||||
|
@@ -226,7 +226,7 @@ export const runToolWithFunctionCall = async (
|
||||
toolName: '',
|
||||
toolAvatar: '',
|
||||
params: '',
|
||||
response: sliceStrStartEnd(stringToolResponse, 300, 300)
|
||||
response: sliceStrStartEnd(stringToolResponse, 500, 500)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@@ -204,7 +204,7 @@ export const dispatchRunTools = async (props: DispatchToolModuleProps): Promise<
|
||||
toolCallTokens: totalTokens,
|
||||
model: modelName,
|
||||
query: userChatInput,
|
||||
historyPreview: getHistoryPreview(GPTMessages2Chats(completeMessages, false)),
|
||||
historyPreview: getHistoryPreview(GPTMessages2Chats(completeMessages, false), 10000),
|
||||
toolDetail: childToolResponse
|
||||
},
|
||||
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [
|
||||
|
@@ -255,7 +255,7 @@ export const runToolWithPromptCall = async (
|
||||
toolName: '',
|
||||
toolAvatar: '',
|
||||
params: '',
|
||||
response: sliceStrStartEnd(stringToolResponse, 300, 300)
|
||||
response: sliceStrStartEnd(stringToolResponse, 500, 500)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@@ -235,7 +235,7 @@ export const runToolWithToolChoice = async (
|
||||
toolName: '',
|
||||
toolAvatar: '',
|
||||
params: '',
|
||||
response: sliceStrStartEnd(stringToolResponse, 300, 300)
|
||||
response: sliceStrStartEnd(stringToolResponse, 500, 500)
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@@ -221,7 +221,7 @@ export const dispatchChatCompletion = async (props: ChatProps): Promise<ChatResp
|
||||
tokens,
|
||||
query: `${userChatInput}`,
|
||||
maxToken: max_tokens,
|
||||
historyPreview: getHistoryPreview(chatCompleteMessages),
|
||||
historyPreview: getHistoryPreview(chatCompleteMessages, 10000),
|
||||
contextTotalLen: completeMessages.length
|
||||
},
|
||||
[DispatchNodeResponseKeyEnum.nodeDispatchUsages]: [
|
||||
|
@@ -1088,7 +1088,8 @@
|
||||
"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 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": {
|
||||
"App": "Select app",
|
||||
|
@@ -598,8 +598,7 @@
|
||||
"success": "开始同步"
|
||||
}
|
||||
},
|
||||
"training": {
|
||||
}
|
||||
"training": {}
|
||||
},
|
||||
"data": {
|
||||
"Auxiliary Data": "辅助数据",
|
||||
@@ -1095,7 +1094,7 @@
|
||||
"change_owner_failed": "转移所有权失败",
|
||||
"change_owner_placeholder": "输入用户名查找账号",
|
||||
"change_owner_success": "成功转移所有权",
|
||||
"change_owner_tip": "转移后将保留您的管理员权限",
|
||||
"change_owner_tip": "转移后您的权限不会保留",
|
||||
"change_owner_to": "转移给"
|
||||
},
|
||||
"plugin": {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "app",
|
||||
"version": "4.8.8",
|
||||
"version": "4.8.9",
|
||||
"private": false,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
@@ -20,11 +20,11 @@ export const workflowBoxStyles: FlexProps = {
|
||||
export const publishStatusStyle = {
|
||||
unPublish: {
|
||||
colorSchema: 'adora' as any,
|
||||
text: i18nT('common:core.app.have_publish')
|
||||
text: i18nT('common:core.app.not_published')
|
||||
},
|
||||
published: {
|
||||
colorSchema: 'green' as any,
|
||||
text: i18nT('common:core.app.not_published')
|
||||
text: i18nT('common:core.app.have_publish')
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import PageContainer from '@/components/PageContainer';
|
||||
import ChatHeader from './components/ChatHeader';
|
||||
import ChatHistorySlider from './components/ChatHistorySlider';
|
||||
import { serviceSideProps } from '@/web/common/utils/i18n';
|
||||
import { checkChatSupportSelectFileByChatModels } from '@/web/core/chat/utils';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { delChatRecordById, getChatHistories, getInitOutLinkChatInfo } from '@/web/core/chat/api';
|
||||
import { getChatTitleFromChatMessage } from '@fastgpt/global/core/chat/utils';
|
||||
@@ -97,7 +96,13 @@ const OutLink = ({ appName, appIntro, appAvatar }: Props) => {
|
||||
} = useChat();
|
||||
|
||||
const startChat = useCallback(
|
||||
async ({ messages, controller, generatingMessage, variables }: StartChatFnProps) => {
|
||||
async ({
|
||||
messages,
|
||||
controller,
|
||||
generatingMessage,
|
||||
variables,
|
||||
responseChatItemId
|
||||
}: StartChatFnProps) => {
|
||||
const completionChatId = chatId || getNanoid();
|
||||
const histories = messages.slice(-1);
|
||||
|
||||
@@ -119,6 +124,7 @@ const OutLink = ({ appName, appIntro, appAvatar }: Props) => {
|
||||
...variables,
|
||||
...customVariables
|
||||
},
|
||||
responseChatItemId,
|
||||
shareId,
|
||||
chatId: completionChatId,
|
||||
appType: chatData.app.type,
|
||||
|
@@ -79,7 +79,13 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
|
||||
} = useChat();
|
||||
|
||||
const startChat = useCallback(
|
||||
async ({ messages, controller, generatingMessage, variables }: StartChatFnProps) => {
|
||||
async ({
|
||||
messages,
|
||||
controller,
|
||||
generatingMessage,
|
||||
variables,
|
||||
responseChatItemId
|
||||
}: StartChatFnProps) => {
|
||||
const completionChatId = chatId || getNanoid();
|
||||
// Just send a user prompt
|
||||
const histories = messages.slice(-1);
|
||||
@@ -91,6 +97,7 @@ const Chat = ({ myApps }: { myApps: AppListItemType[] }) => {
|
||||
...variables,
|
||||
...customVariables
|
||||
},
|
||||
responseChatItemId,
|
||||
appId,
|
||||
teamId,
|
||||
teamToken,
|
||||
|
Reference in New Issue
Block a user