diff --git a/web/src/pages/agent/chat/box.tsx b/web/src/pages/agent/chat/box.tsx index 2e2010fc5..9fd1d2db5 100644 --- a/web/src/pages/agent/chat/box.tsx +++ b/web/src/pages/agent/chat/box.tsx @@ -16,7 +16,7 @@ import { useFetchUserInfo } from '@/hooks/user-setting-hooks'; import { Message } from '@/interfaces/database/chat'; import { buildMessageUuidWithRole } from '@/utils/chat'; import { get } from 'lodash'; -import { memo, useCallback } from 'react'; +import { memo, useCallback, useMemo } from 'react'; import { useParams } from 'umi'; import DebugContent from '../debug-content'; import { BeginQuery } from '../interface'; @@ -43,7 +43,6 @@ function AgentChatBox() { const { data: canvasInfo } = useFetchAgent(); const { id: canvasId } = useParams(); const { uploadCanvasFile, loading } = useUploadCanvasFileWithProgress(); - const getInputs = useCallback((message: Message) => { return get(message, 'data.inputs', {}) as Record; }, []); @@ -80,7 +79,16 @@ function AgentChatBox() { }, [appendUploadResponseList, uploadCanvasFile], ); - + const isWaitting = useMemo(() => { + const temp = derivedMessages?.some((message, i) => { + const flag = + message.role === MessageType.Assistant && + derivedMessages.length - 1 === i && + message.data; + return flag; + }); + return temp; + }, [derivedMessages]); return ( <>
@@ -106,12 +114,26 @@ function AgentChatBox() { showLikeButton={false} sendLoading={sendLoading} > - + {message.role === MessageType.Assistant && + derivedMessages.length - 1 === i && ( + + )} + {message.role === MessageType.Assistant && + derivedMessages.length - 1 !== i && ( +
+
{message?.data?.tips}
+ +
+ {buildInputList(message)?.map((item) => item.value)} +
+
+ )} ); })} @@ -122,9 +144,9 @@ function AgentChatBox() {
+ {message?.data?.tips &&
{message.data.tips}
}
{parameters.map((x, idx) => { @@ -242,7 +245,7 @@ const DebugContent = ({ type="submit" loading={loading} disabled={!submittable || submitButtonDisabled} - className="w-full mt-8" + className="w-full mt-1" > {btnText || t(isNext ? 'common.next' : 'flow.run')} diff --git a/web/src/pages/agent/log-sheet/toolTimelineItem.tsx b/web/src/pages/agent/log-sheet/toolTimelineItem.tsx index dac7c0817..45bcfc0f3 100644 --- a/web/src/pages/agent/log-sheet/toolTimelineItem.tsx +++ b/web/src/pages/agent/log-sheet/toolTimelineItem.tsx @@ -12,6 +12,7 @@ import { AccordionTrigger, } from '@/components/ui/accordion'; import { cn } from '@/lib/utils'; +import { isEmpty } from 'lodash'; import { Operator } from '../constant'; import OperatorIcon from '../operator-icon'; import { @@ -19,7 +20,20 @@ import { toLowerCaseStringAndDeleteChar, typeMap, } from './workFlowTimeline'; +const capitalizeWords = (str: string, separator: string = '_'): string => { + if (!str) return ''; + return str + .split(separator) + .map((word) => { + return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); + }) + .join(' '); +}; +const changeToolName = (toolName: any) => { + const name = 'Agent ' + capitalizeWords(toolName); + return name; +}; const ToolTimelineItem = ({ tools, sendLoading = false, @@ -34,16 +48,7 @@ const ToolTimelineItem = ({ const filteredTools = tools.filter( (tool) => !blackList.includes(tool.tool_name), ); - const capitalizeWords = (str: string, separator: string = '_'): string => { - if (!str) return ''; - return str - .split(separator) - .map((word) => { - return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); - }) - .join(' '); - }; const parentName = (str: string, separator: string = '-->') => { if (!str) return ''; const strs = str.split(separator); @@ -124,13 +129,11 @@ const ToolTimelineItem = ({ )} {isShare && ( - { - typeMap[ - toLowerCaseStringAndDeleteChar( - tool.tool_name, - ) as keyof typeof typeMap - ] - } + {typeMap[ + toLowerCaseStringAndDeleteChar( + tool.tool_name, + ) as keyof typeof typeMap + ] ?? changeToolName(tool.tool_name)} )} @@ -146,22 +149,37 @@ const ToolTimelineItem = ({ - -
- {!isShare && ( + {!isShare && ( + +
- )} - {isShare && ( - - )} -
-
+
+
+ )} + {isShare && !isEmpty(tool.arguments) && ( + +
+ {tool && + tool.arguments && + Object.entries(tool.arguments).length && + Object.entries(tool.arguments).map(([key, val]) => { + return ( +
+
+ {key} +
+
+ {val || ''} +
+
+ ); + })} +
+
+ )}
diff --git a/web/src/pages/agents/agent-log-page.tsx b/web/src/pages/agents/agent-log-page.tsx index 461c33397..9ec106487 100644 --- a/web/src/pages/agents/agent-log-page.tsx +++ b/web/src/pages/agents/agent-log-page.tsx @@ -144,12 +144,14 @@ const AgentLogPage: React.FC = () => { const handlePageChange = (current?: number, pageSize?: number) => { console.log('current', current, 'pageSize', pageSize); - setPagination((pre) => { - return { - ...pre, - current: current ?? pre.pageSize ? 1 : pre.current, - pageSize: pageSize ?? pre.pageSize, - }; + let page = current || 1; + if (pagination.pageSize !== pageSize) { + page = 1; + } + setPagination({ + ...pagination, + current: page, + pageSize: pageSize || 10, }); };