mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 00:56:26 +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)
|
||||
};
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user