Skip to content

Commit 008b42d

Browse files
newfish-cmykc121914yu
authored andcommitted
fix
1 parent 8329746 commit 008b42d

File tree

5 files changed

+217
-183
lines changed

5 files changed

+217
-183
lines changed

packages/web/i18n/en/app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"document_upload": "Document Upload",
9696
"edit_app": "Application details",
9797
"edit_info": "Edit",
98+
"empty_tool_tips": "Please add tools on the left side",
9899
"execute_time": "Execution Time",
99100
"export_config_successful": "Configuration copied, some sensitive information automatically filtered. Please check for any remaining sensitive data.",
100101
"export_configs": "Export",
@@ -105,6 +106,8 @@
105106
"file_upload_tip": "Once enabled, documents/images can be uploaded. Documents are retained for 7 days, images for 15 days. Using this feature may incur additional costs. To ensure a good experience, please choose an AI model with a larger context length when using this feature.",
106107
"go_to_chat": "Go to Conversation",
107108
"go_to_run": "Go to Execution",
109+
"http_toolset_add_tips": "Click the \"Add\" button to add tools",
110+
"http_toolset_config_tips": "Click \"Start Configuration\" to add tools",
108111
"image_upload": "Image Upload",
109112
"image_upload_tip": "How to activate model image recognition capabilities",
110113
"import_configs": "Import",

packages/web/i18n/zh-CN/app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"edit_app": "应用详情",
9999
"edit_info": "编辑信息",
100100
"edit_param": "编辑参数",
101+
"empty_tool_tips": "请在左侧添加工具",
101102
"execute_time": "执行时间",
102103
"export_config_successful": "已复制配置,自动过滤部分敏感信息,请注意检查是否仍有敏感数据",
103104
"export_configs": "导出配置",
@@ -108,6 +109,8 @@
108109
"file_upload_tip": "开启后,可以上传文档/图片。文档保留7天,图片保留15天。使用该功能可能产生较多额外费用。为保证使用体验,使用该功能时,请选择上下文长度较大的AI模型。",
109110
"go_to_chat": "去对话",
110111
"go_to_run": "去运行",
112+
"http_toolset_add_tips": "点击添加按钮来添加工具",
113+
"http_toolset_config_tips": "点击开始配置来添加工具",
111114
"image_upload": "图片上传",
112115
"image_upload_tip": "如何启动模型图片识别能力",
113116
"import_configs": "导入配置",

packages/web/i18n/zh-Hant/app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"document_upload": "文件上傳",
9696
"edit_app": "應用詳情",
9797
"edit_info": "編輯資訊",
98+
"empty_tool_tips": "請在左側添加工具",
9899
"execute_time": "執行時間",
99100
"export_config_successful": "已複製設定,自動過濾部分敏感資訊,請注意檢查是否仍有敏感資料",
100101
"export_configs": "匯出設定",
@@ -105,6 +106,8 @@
105106
"file_upload_tip": "開啟後,可以上傳文件/圖片。文件保留 7 天,圖片保留 15 天。使用這個功能可能產生較多額外費用。為了確保使用體驗,使用這個功能時,請選擇上下文長度較大的 AI 模型。",
106107
"go_to_chat": "前往對話",
107108
"go_to_run": "前往執行",
109+
"http_toolset_add_tips": "點擊添加按鈕來添加工具",
110+
"http_toolset_config_tips": "點擊開始配置來添加工具",
108111
"image_upload": "圖片上傳",
109112
"image_upload_tip": "如何啟用模型圖片辨識功能",
110113
"import_configs": "匯入設定",

projects/app/src/pageComponents/app/detail/HTTPTools/ChatTest.tsx

Lines changed: 73 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useContextSelector } from 'use-context-selector';
44
import { AppContext } from '../context';
55
import ChatItemContextProvider from '@/web/core/chat/context/chatItemContext';
66
import ChatRecordContextProvider from '@/web/core/chat/context/chatRecordContext';
7-
import { Box, Button, Flex, HStack } from '@chakra-ui/react';
7+
import { Box, Button, Center, Flex, HStack } from '@chakra-ui/react';
88
import { cardStyles } from '../constants';
99
import { useTranslation } from 'next-i18next';
1010
import { type HttpToolConfigType } from '@fastgpt/global/core/app/type';
@@ -19,6 +19,7 @@ import LabelAndFormRender from '@/components/core/app/formRender/LabelAndForm';
1919
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
2020
import ValueTypeLabel from '../WorkflowComponents/Flow/nodes/render/ValueTypeLabel';
2121
import LightRowTabs from '@fastgpt/web/components/common/Tabs/LightRowTabs';
22+
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
2223

2324
const ChatTest = ({
2425
currentTool,
@@ -82,6 +83,7 @@ const ChatTest = ({
8283
errorToast: 'test'
8384
}
8485
);
86+
console.log(currentTool);
8587

8688
return (
8789
<Flex h={'full'} gap={2}>
@@ -103,73 +105,81 @@ const ChatTest = ({
103105
<Box flex={1} />
104106
</Flex>
105107

106-
<Box px={[2, 5]} mb={6}>
107-
<LightRowTabs
108-
gap={4}
109-
list={tabList}
110-
value={activeTab}
111-
onChange={(value) => {
112-
setActiveTab(value);
113-
}}
114-
/>
115-
</Box>
108+
{!currentTool ? (
109+
<Center>
110+
<EmptyTip text={t('app:empty_tool_tips')} />
111+
</Center>
112+
) : (
113+
<>
114+
<Box px={[2, 5]} mb={6}>
115+
<LightRowTabs
116+
gap={4}
117+
list={tabList}
118+
value={activeTab}
119+
onChange={(value) => {
120+
setActiveTab(value);
121+
}}
122+
/>
123+
</Box>
116124

117-
{activeTab === 'input' ? (
118-
<Box flex={1} px={[2, 5]} overflow={'auto'}>
119-
{Object.keys(currentTool?.inputSchema.properties || {}).length > 0 ? (
120-
<>
121-
<Box border={'1px solid'} borderColor={'myGray.200'} borderRadius={'8px'} p={3}>
122-
{Object.entries(currentTool?.inputSchema.properties || {}).map(
123-
([paramName, paramInfo]) => {
124-
const inputType = valueTypeToInputType(
125-
getNodeInputTypeFromSchemaInputType({ type: paramInfo.type })
126-
);
127-
const required = currentTool?.inputSchema.required?.includes(paramName);
125+
{activeTab === 'input' ? (
126+
<Box flex={1} px={[2, 5]} overflow={'auto'}>
127+
{Object.keys(currentTool?.inputSchema.properties || {}).length > 0 ? (
128+
<>
129+
<Box border={'1px solid'} borderColor={'myGray.200'} borderRadius={'8px'} p={3}>
130+
{Object.entries(currentTool?.inputSchema.properties || {}).map(
131+
([paramName, paramInfo]) => {
132+
const inputType = valueTypeToInputType(
133+
getNodeInputTypeFromSchemaInputType({ type: paramInfo.type })
134+
);
135+
const required = currentTool?.inputSchema.required?.includes(paramName);
128136

129-
return (
130-
<LabelAndFormRender
131-
label={
132-
<HStack spacing={0} mr={2}>
133-
<FormLabel required={required}>{paramName}</FormLabel>
134-
<ValueTypeLabel
135-
valueType={getNodeInputTypeFromSchemaInputType({
136-
type: paramInfo.type,
137-
arrayItems: paramInfo.items
138-
})}
139-
h={'auto'}
140-
/>
141-
</HStack>
142-
}
143-
required={required}
144-
key={paramName}
145-
inputType={inputType}
146-
fieldName={paramName}
147-
form={form}
148-
placeholder={paramName}
149-
/>
150-
);
151-
}
152-
)}
153-
</Box>
154-
</>
155-
) : (
156-
<Box fontWeight={'medium'} pb={4} px={2}>
157-
{t('app:this_tool_requires_no_input')}
158-
</Box>
159-
)}
137+
return (
138+
<LabelAndFormRender
139+
label={
140+
<HStack spacing={0} mr={2}>
141+
<FormLabel required={required}>{paramName}</FormLabel>
142+
<ValueTypeLabel
143+
valueType={getNodeInputTypeFromSchemaInputType({
144+
type: paramInfo.type,
145+
arrayItems: paramInfo.items
146+
})}
147+
h={'auto'}
148+
/>
149+
</HStack>
150+
}
151+
required={required}
152+
key={paramName}
153+
inputType={inputType}
154+
fieldName={paramName}
155+
form={form}
156+
placeholder={paramName}
157+
/>
158+
);
159+
}
160+
)}
161+
</Box>
162+
</>
163+
) : (
164+
<Box fontWeight={'medium'} pb={4} px={2}>
165+
{t('app:this_tool_requires_no_input')}
166+
</Box>
167+
)}
160168

161-
<Button mt={3} isLoading={isRunning} onClick={handleSubmit(runTool)}>
162-
{t('common:Run')}
163-
</Button>
164-
</Box>
165-
) : (
166-
<Box flex={1} px={[2, 5]} overflow={'auto'}>
167-
{output && (
168-
<Box>
169-
<Markdown source={`~~~json\n${output}`} />
169+
<Button mt={3} isLoading={isRunning} onClick={handleSubmit(runTool)}>
170+
{t('common:Run')}
171+
</Button>
172+
</Box>
173+
) : (
174+
<Box flex={1} px={[2, 5]} overflow={'auto'}>
175+
{output && (
176+
<Box>
177+
<Markdown source={`~~~json\n${output}`} />
178+
</Box>
179+
)}
170180
</Box>
171181
)}
172-
</Box>
182+
</>
173183
)}
174184
</Box>
175185
</Flex>

0 commit comments

Comments
 (0)