diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx index 164d4b6f9..609facc65 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/ChatItem.tsx @@ -251,6 +251,7 @@ const ChatItem = (props: Props) => { chatId: chatId, chatItemDataId: chat.dataId, collectionId: collectionId, + collectionIdList, sourceId: sourceId || '', sourceName: sourceName || '', datasetId: datasetId || '', @@ -272,11 +273,12 @@ const ChatItem = (props: Props) => { ); useEffect(() => { + if (chat.obj !== ChatRoleEnum.AI) return; eventBus.on(EventNameEnum.openQuoteReader, handleOpenQuoteReader); return () => { eventBus.off(EventNameEnum.openQuoteReader); }; - }, [handleOpenQuoteReader]); + }, [chat.obj, handleOpenQuoteReader]); return ( v.isResponseDetail); + + const source = useMemo(() => { + if (!text) return ''; + + // Remove quote references if not showing response detail + return isResponseDetail ? text : text.replace(/\[[a-f0-9]{24}\]\(QUOTE\)/g, ''); + }, [text, isResponseDetail]); + // First empty line // if (!source && !isLastChild) return null; diff --git a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx index 89319f960..f129b1d34 100644 --- a/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx +++ b/projects/app/src/pageComponents/app/detail/Logs/DetailLogsModal.tsx @@ -213,6 +213,7 @@ const Render = (props: Props) => { showRouteToAppDetail={true} showRouteToDatasetDetail={true} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx index e7571e682..05c6ac271 100644 --- a/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/MCPTools/ChatTest.tsx @@ -152,6 +152,7 @@ const Render = ({ currentTool, url }: { currentTool: ToolType | null; url: strin showRouteToAppDetail={true} showRouteToDatasetDetail={true} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx index 1ea84c8d9..137e966ae 100644 --- a/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/SimpleApp/ChatTest.tsx @@ -119,6 +119,7 @@ const Render = ({ appForm, setRenderEdit }: Props) => { showRouteToAppDetail={true} showRouteToDatasetDetail={true} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx index 5fa563315..0c60264f4 100644 --- a/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx +++ b/projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/ChatTest.tsx @@ -195,6 +195,7 @@ const Render = (Props: Props) => { showRouteToAppDetail={true} showRouteToDatasetDetail={true} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/pages/api/core/app/httpPlugin/create.ts b/projects/app/src/pages/api/core/app/httpPlugin/create.ts index ec4be89f4..4deca5c2c 100644 --- a/projects/app/src/pages/api/core/app/httpPlugin/create.ts +++ b/projects/app/src/pages/api/core/app/httpPlugin/create.ts @@ -35,9 +35,9 @@ async function handler( ? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true }) : await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal }); - await mongoSessionRun(async (session) => { + const httpPluginId = await mongoSessionRun(async (session) => { // create http plugin folder - const httpPluginIid = await onCreateApp({ + const httpPluginId = await onCreateApp({ parentId, name, avatar, @@ -51,7 +51,7 @@ async function handler( // compute children plugins const childrenPlugins = await httpApiSchema2Plugins({ - parentId: httpPluginIid, + parentId: httpPluginId, apiSchemaStr: pluginData.apiSchemaStr, customHeader: pluginData.customHeaders }); @@ -65,10 +65,13 @@ async function handler( session }); } + + return httpPluginId; }); pushTrack.createApp({ type: AppTypeEnum.httpPlugin, + appId: httpPluginId, uid: userId, teamId, tmbId diff --git a/projects/app/src/pages/api/core/app/mcpTools/create.ts b/projects/app/src/pages/api/core/app/mcpTools/create.ts index 3355d95fb..a23980cfe 100644 --- a/projects/app/src/pages/api/core/app/mcpTools/create.ts +++ b/projects/app/src/pages/api/core/app/mcpTools/create.ts @@ -35,7 +35,7 @@ async function handler( ? await authApp({ req, appId: parentId, per: TeamAppCreatePermissionVal, authToken: true }) : await authUserPer({ req, authToken: true, per: TeamAppCreatePermissionVal }); - await mongoSessionRun(async (session) => { + const mcpToolsId = await mongoSessionRun(async (session) => { const mcpToolsId = await onCreateApp({ name, avatar, @@ -60,10 +60,13 @@ async function handler( session }); } + + return mcpToolsId; }); pushTrack.createApp({ type: AppTypeEnum.toolSet, + appId: mcpToolsId, uid: userId, teamId, tmbId diff --git a/projects/app/src/pages/chat/index.tsx b/projects/app/src/pages/chat/index.tsx index 6f78faa28..b0a3ea70b 100644 --- a/projects/app/src/pages/chat/index.tsx +++ b/projects/app/src/pages/chat/index.tsx @@ -294,6 +294,7 @@ const Render = (props: { appId: string; isStandalone?: string }) => { showRouteToAppDetail={isStandalone !== '1'} showRouteToDatasetDetail={isStandalone !== '1'} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/pages/chat/share.tsx b/projects/app/src/pages/chat/share.tsx index b928303a5..d9f66c94a 100644 --- a/projects/app/src/pages/chat/share.tsx +++ b/projects/app/src/pages/chat/share.tsx @@ -50,6 +50,7 @@ type Props = { authToken: string; customUid: string; showRawSource: boolean; + responseDetail: boolean; // showFullText: boolean; showNodeStatus: boolean; }; @@ -369,6 +370,7 @@ const Render = (props: Props) => { showRouteToAppDetail={false} showRouteToDatasetDetail={false} isShowReadRawSource={props.showRawSource} + isResponseDetail={props.responseDetail} // isShowFullText={props.showFullText} showNodeStatus={props.showNodeStatus} > @@ -395,7 +397,7 @@ export async function getServerSideProps(context: any) { { shareId }, - 'appId showRawSource showNodeStatus' + 'appId showRawSource showNodeStatus responseDetail' ) .populate<{ associatedApp: AppSchema }>('associatedApp', 'name avatar intro') .lean(); @@ -412,6 +414,7 @@ export async function getServerSideProps(context: any) { appAvatar: app?.associatedApp?.avatar ?? '', appIntro: app?.associatedApp?.intro ?? 'AI', showRawSource: app?.showRawSource ?? false, + responseDetail: app?.responseDetail ?? false, // showFullText: app?.showFullText ?? false, showNodeStatus: app?.showNodeStatus ?? false, shareId: shareId ?? '', diff --git a/projects/app/src/pages/chat/team.tsx b/projects/app/src/pages/chat/team.tsx index af46cd216..dfcf92e30 100644 --- a/projects/app/src/pages/chat/team.tsx +++ b/projects/app/src/pages/chat/team.tsx @@ -314,6 +314,7 @@ const Render = (props: Props) => { showRouteToAppDetail={false} showRouteToDatasetDetail={false} isShowReadRawSource={true} + isResponseDetail={true} // isShowFullText={true} showNodeStatus > diff --git a/projects/app/src/web/core/chat/context/chatItemContext.tsx b/projects/app/src/web/core/chat/context/chatItemContext.tsx index fba34f550..39c946ee3 100644 --- a/projects/app/src/web/core/chat/context/chatItemContext.tsx +++ b/projects/app/src/web/core/chat/context/chatItemContext.tsx @@ -15,6 +15,7 @@ type ContextProps = { showRouteToAppDetail: boolean; showRouteToDatasetDetail: boolean; isShowReadRawSource: boolean; + isResponseDetail: boolean; // isShowFullText: boolean; showNodeStatus: boolean; }; @@ -115,6 +116,7 @@ const ChatItemContextProvider = ({ showRouteToAppDetail, showRouteToDatasetDetail, isShowReadRawSource, + isResponseDetail, // isShowFullText, showNodeStatus }: { @@ -177,6 +179,7 @@ const ChatItemContextProvider = ({ showRouteToAppDetail, showRouteToDatasetDetail, isShowReadRawSource, + isResponseDetail, // isShowFullText, showNodeStatus, @@ -195,6 +198,7 @@ const ChatItemContextProvider = ({ showRouteToAppDetail, showRouteToDatasetDetail, isShowReadRawSource, + isResponseDetail, // isShowFullText, showNodeStatus, quoteData,