mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 22:03:54 +00:00
Test parse cite and add tool call parallel (#4737)
* add quote response filter (#4727) * chatting * add quote response filter * add test * remove comment * perf: cite hidden * perf: format llm response * feat: comment * update default chunk size * update default chunk size --------- Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
import { DispatchNodeResponseType } from '../workflow/runtime/type';
|
||||
import { FlowNodeTypeEnum } from '../workflow/node/constant';
|
||||
import { ChatItemValueTypeEnum, ChatRoleEnum, ChatSourceEnum } from './constants';
|
||||
import { ChatHistoryItemResType, ChatItemType, UserChatItemValueItemType } from './type.d';
|
||||
import {
|
||||
AIChatItemValueItemType,
|
||||
ChatHistoryItemResType,
|
||||
ChatItemType,
|
||||
UserChatItemValueItemType
|
||||
} from './type.d';
|
||||
import { sliceStrStartEnd } from '../../common/string/tools';
|
||||
import { PublishChannelEnum } from '../../support/outLink/constant';
|
||||
import { removeDatasetCiteText } from '../../../service/core/ai/utils';
|
||||
|
||||
// Concat 2 -> 1, and sort by role
|
||||
export const concatHistories = (histories1: ChatItemType[], histories2: ChatItemType[]) => {
|
||||
@@ -77,6 +83,7 @@ export const getHistoryPreview = (
|
||||
});
|
||||
};
|
||||
|
||||
// Filter workflow public response
|
||||
export const filterPublicNodeResponseData = ({
|
||||
flowResponses = [],
|
||||
responseDetail = false
|
||||
@@ -112,6 +119,40 @@ export const filterPublicNodeResponseData = ({
|
||||
});
|
||||
};
|
||||
|
||||
// Remove dataset cite in ai response
|
||||
export const removeAIResponseCite = <T extends AIChatItemValueItemType[] | string>(
|
||||
value: T,
|
||||
retainCite: boolean
|
||||
): T => {
|
||||
if (retainCite) return value;
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return removeDatasetCiteText(value, false) as T;
|
||||
}
|
||||
|
||||
return value.map<AIChatItemValueItemType>((item) => {
|
||||
if (item.text?.content) {
|
||||
return {
|
||||
...item,
|
||||
text: {
|
||||
...item.text,
|
||||
content: removeDatasetCiteText(item.text.content, false)
|
||||
}
|
||||
};
|
||||
}
|
||||
if (item.reasoning?.content) {
|
||||
return {
|
||||
...item,
|
||||
reasoning: {
|
||||
...item.reasoning,
|
||||
content: removeDatasetCiteText(item.reasoning.content, false)
|
||||
}
|
||||
};
|
||||
}
|
||||
return item;
|
||||
}) as T;
|
||||
};
|
||||
|
||||
export const removeEmptyUserInput = (input?: UserChatItemValueItemType[]) => {
|
||||
return (
|
||||
input?.filter((item) => {
|
||||
|
Reference in New Issue
Block a user