mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-14 15:11:13 +00:00
perf: plan agent name
This commit is contained in:
@@ -22,8 +22,15 @@ import {
|
|||||||
} from '@fastgpt/global/core/chat/adapt';
|
} from '@fastgpt/global/core/chat/adapt';
|
||||||
import { formatModelChars2Points } from '../../../../../support/wallet/usage/utils';
|
import { formatModelChars2Points } from '../../../../../support/wallet/usage/utils';
|
||||||
import { getHistoryPreview } from '@fastgpt/global/core/chat/utils';
|
import { getHistoryPreview } from '@fastgpt/global/core/chat/utils';
|
||||||
import { filterMemoryMessages, filterToolResponseToPreview, parseToolArgs } from '../utils';
|
import {
|
||||||
import { SubAppIds } from './sub/constants';
|
filterMemoryMessages,
|
||||||
|
filterToolResponseToPreview,
|
||||||
|
formatToolResponse,
|
||||||
|
getToolNodesByIds,
|
||||||
|
initToolNodes,
|
||||||
|
parseToolArgs
|
||||||
|
} from '../utils';
|
||||||
|
import { SubAppIds, systemSubInfo } from './sub/constants';
|
||||||
import {
|
import {
|
||||||
getReferenceVariableValue,
|
getReferenceVariableValue,
|
||||||
replaceEditorVariable,
|
replaceEditorVariable,
|
||||||
@@ -139,7 +146,7 @@ export const dispatchRunAgent = async (props: DispatchAgentModuleProps): Promise
|
|||||||
// Init tool params
|
// Init tool params
|
||||||
const toolNodesMap = new Map(runtimeSubApps.map((item) => [item.nodeId, item]));
|
const toolNodesMap = new Map(runtimeSubApps.map((item) => [item.nodeId, item]));
|
||||||
const getToolInfo = (id: string) => {
|
const getToolInfo = (id: string) => {
|
||||||
const toolNode = toolNodesMap.get(id);
|
const toolNode = toolNodesMap.get(id) || systemSubInfo[id];
|
||||||
return {
|
return {
|
||||||
name: toolNode?.name || '',
|
name: toolNode?.name || '',
|
||||||
avatar: toolNode?.avatar || ''
|
avatar: toolNode?.avatar || ''
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import type { ChatCompletionTool } from '@fastgpt/global/core/ai/type';
|
import type { ChatCompletionTool } from '@fastgpt/global/core/ai/type';
|
||||||
|
import { i18nT } from '../../../../../../../web/i18n/utils';
|
||||||
|
|
||||||
export enum SubAppIds {
|
export enum SubAppIds {
|
||||||
plan = 'plan_agent',
|
plan = 'plan_agent',
|
||||||
@@ -7,3 +8,26 @@ export enum SubAppIds {
|
|||||||
model = 'model_agent',
|
model = 'model_agent',
|
||||||
fileRead = 'file_read'
|
fileRead = 'file_read'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const systemSubInfo: Record<string, { name: string; avatar: string }> = {
|
||||||
|
[SubAppIds.plan]: {
|
||||||
|
name: i18nT('chat:plan_agent'),
|
||||||
|
avatar: 'common/detail'
|
||||||
|
},
|
||||||
|
[SubAppIds.fileRead]: {
|
||||||
|
name: i18nT('chat:file_parse'),
|
||||||
|
avatar: 'core/workflow/template/readFiles'
|
||||||
|
},
|
||||||
|
[SubAppIds.ask]: {
|
||||||
|
name: 'Ask Agent',
|
||||||
|
avatar: 'core/workflow/template/agent'
|
||||||
|
},
|
||||||
|
[SubAppIds.stop]: {
|
||||||
|
name: 'Stop Agent',
|
||||||
|
avatar: 'core/workflow/template/agent'
|
||||||
|
},
|
||||||
|
[SubAppIds.model]: {
|
||||||
|
name: 'Model Agent',
|
||||||
|
avatar: 'core/workflow/template/agent'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
"file_amount_over": "Exceeded maximum file quantity {{max}}",
|
"file_amount_over": "Exceeded maximum file quantity {{max}}",
|
||||||
"file_input": "File input",
|
"file_input": "File input",
|
||||||
"file_input_tip": "You can obtain the link to the corresponding file through the \"File Link\" of the [Plug-in Start] node",
|
"file_input_tip": "You can obtain the link to the corresponding file through the \"File Link\" of the [Plug-in Start] node",
|
||||||
|
"file_parse": "File parsing",
|
||||||
"history_slider.home.title": "chat",
|
"history_slider.home.title": "chat",
|
||||||
"home.chat_app": "HomeChat-{{name}}",
|
"home.chat_app": "HomeChat-{{name}}",
|
||||||
"home.chat_id": "Chat ID",
|
"home.chat_id": "Chat ID",
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
"no_workflow_response": "No workflow data",
|
"no_workflow_response": "No workflow data",
|
||||||
"not_query": "Missing query content",
|
"not_query": "Missing query content",
|
||||||
"not_select_file": "No file selected",
|
"not_select_file": "No file selected",
|
||||||
|
"plan_agent": "Plan agent",
|
||||||
"plugins_output": "Plugin Output",
|
"plugins_output": "Plugin Output",
|
||||||
"press_to_speak": "Hold down to speak",
|
"press_to_speak": "Hold down to speak",
|
||||||
"query_extension_IO_tokens": "Problem Optimization Input/Output Tokens",
|
"query_extension_IO_tokens": "Problem Optimization Input/Output Tokens",
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
"file_amount_over": "超出最大文件数量 {{max}}",
|
"file_amount_over": "超出最大文件数量 {{max}}",
|
||||||
"file_input": "系统文件",
|
"file_input": "系统文件",
|
||||||
"file_input_tip": "可通过【插件开始】节点的“文件链接”获取对应文件的链接",
|
"file_input_tip": "可通过【插件开始】节点的“文件链接”获取对应文件的链接",
|
||||||
|
"file_parse": "文件解析",
|
||||||
"history_slider.home.title": "聊天",
|
"history_slider.home.title": "聊天",
|
||||||
"home.chat_app": "首页聊天",
|
"home.chat_app": "首页聊天",
|
||||||
"home.chat_id": "会话ID",
|
"home.chat_id": "会话ID",
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
"no_workflow_response": "没有运行数据",
|
"no_workflow_response": "没有运行数据",
|
||||||
"not_query": "缺少查询内容",
|
"not_query": "缺少查询内容",
|
||||||
"not_select_file": "未选择文件",
|
"not_select_file": "未选择文件",
|
||||||
|
"plan_agent": "任务规划",
|
||||||
"plugins_output": "插件输出",
|
"plugins_output": "插件输出",
|
||||||
"press_to_speak": "按住说话",
|
"press_to_speak": "按住说话",
|
||||||
"query_extension_IO_tokens": "问题优化输入/输出 Tokens",
|
"query_extension_IO_tokens": "问题优化输入/输出 Tokens",
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
"file_amount_over": "超出檔案數量上限 {{max}}",
|
"file_amount_over": "超出檔案數量上限 {{max}}",
|
||||||
"file_input": "檔案輸入",
|
"file_input": "檔案輸入",
|
||||||
"file_input_tip": "可透過「外掛程式啟動」節點的「檔案連結」取得對應檔案的連結",
|
"file_input_tip": "可透過「外掛程式啟動」節點的「檔案連結」取得對應檔案的連結",
|
||||||
|
"file_parse": "文件解析",
|
||||||
"history_slider.home.title": "聊天",
|
"history_slider.home.title": "聊天",
|
||||||
"home.chat_app": "首页聊天",
|
"home.chat_app": "首页聊天",
|
||||||
"home.chat_id": "會話ID",
|
"home.chat_id": "會話ID",
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
"no_workflow_response": "無工作流程資料",
|
"no_workflow_response": "無工作流程資料",
|
||||||
"not_query": "缺少查詢內容",
|
"not_query": "缺少查詢內容",
|
||||||
"not_select_file": "尚未選取檔案",
|
"not_select_file": "尚未選取檔案",
|
||||||
|
"plan_agent": "任務規劃",
|
||||||
"plugins_output": "外掛程式輸出",
|
"plugins_output": "外掛程式輸出",
|
||||||
"press_to_speak": "按住說話",
|
"press_to_speak": "按住說話",
|
||||||
"query_extension_IO_tokens": "問題最佳化輸入/輸出 Tokens",
|
"query_extension_IO_tokens": "問題最佳化輸入/輸出 Tokens",
|
||||||
|
@@ -16,7 +16,7 @@ import type {
|
|||||||
ToolModuleResponseItemType,
|
ToolModuleResponseItemType,
|
||||||
UserChatItemValueItemType
|
UserChatItemValueItemType
|
||||||
} from '@fastgpt/global/core/chat/type';
|
} from '@fastgpt/global/core/chat/type';
|
||||||
import React, { useCallback, useMemo } from 'react';
|
import React, { useState, useCallback, useMemo } from 'react';
|
||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import Avatar from '@fastgpt/web/components/common/Avatar';
|
import Avatar from '@fastgpt/web/components/common/Avatar';
|
||||||
import type {
|
import type {
|
||||||
@@ -33,6 +33,7 @@ import { useContextSelector } from 'use-context-selector';
|
|||||||
import { type OnOpenCiteModalProps } from '@/web/core/chat/context/chatItemContext';
|
import { type OnOpenCiteModalProps } from '@/web/core/chat/context/chatItemContext';
|
||||||
import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider';
|
import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider';
|
||||||
import { useCreation } from 'ahooks';
|
import { useCreation } from 'ahooks';
|
||||||
|
import { useSafeTranslation } from '@fastgpt/web/hooks/useSafeTranslation';
|
||||||
|
|
||||||
const accordionButtonStyle = {
|
const accordionButtonStyle = {
|
||||||
w: 'auto',
|
w: 'auto',
|
||||||
@@ -131,6 +132,9 @@ const RenderTool = React.memo(
|
|||||||
showAnimation: boolean;
|
showAnimation: boolean;
|
||||||
tools: ToolModuleResponseItemType[];
|
tools: ToolModuleResponseItemType[];
|
||||||
}) {
|
}) {
|
||||||
|
const { t } = useSafeTranslation();
|
||||||
|
const [userOnchange, setUserOnchange] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
{tools.map((tool) => {
|
{tools.map((tool) => {
|
||||||
@@ -145,12 +149,20 @@ const RenderTool = React.memo(
|
|||||||
const toolResponse = formatJson(tool.response);
|
const toolResponse = formatJson(tool.response);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Accordion key={tool.id} allowToggle _notLast={{ mb: 2 }}>
|
<Accordion
|
||||||
|
key={tool.id}
|
||||||
|
allowToggle
|
||||||
|
_notLast={{ mb: 2 }}
|
||||||
|
index={userOnchange ? undefined : showAnimation ? 0 : undefined}
|
||||||
|
onChange={() => {
|
||||||
|
setUserOnchange(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<AccordionItem borderTop={'none'} borderBottom={'none'}>
|
<AccordionItem borderTop={'none'} borderBottom={'none'}>
|
||||||
<AccordionButton {...accordionButtonStyle}>
|
<AccordionButton {...accordionButtonStyle}>
|
||||||
<Avatar src={tool.toolAvatar} w={'1.25rem'} h={'1.25rem'} borderRadius={'sm'} />
|
<Avatar src={tool.toolAvatar} w={'1.25rem'} h={'1.25rem'} borderRadius={'sm'} />
|
||||||
<Box mx={2} fontSize={'sm'} color={'myGray.900'}>
|
<Box mx={2} fontSize={'sm'} color={'myGray.900'}>
|
||||||
{tool.toolName}
|
{t(tool.toolName)}
|
||||||
</Box>
|
</Box>
|
||||||
{showAnimation && !tool.response && <MyIcon name={'common/loading'} w={'14px'} />}
|
{showAnimation && !tool.response && <MyIcon name={'common/loading'} w={'14px'} />}
|
||||||
<AccordionIcon color={'myGray.600'} ml={5} />
|
<AccordionIcon color={'myGray.600'} ml={5} />
|
||||||
|
Reference in New Issue
Block a user