Skip to content

Commit a3fa8aa

Browse files
authored
fix: fixed parameter issues between the model and the assistant (#595)
1 parent f1f8d2c commit a3fa8aa

File tree

10 files changed

+331
-178
lines changed

10 files changed

+331
-178
lines changed

web/src/locales/langs/en-us/page.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,45 @@ const page: App.I18n.Schema['translation']['page'] = {
8282
'The scope of selected vocabulary is limited. The lower the value, the more predictable the result; the higher the value, the more diverse the possibilities. It is not recommended to change this alongside randomness.',
8383
type: 'Type',
8484
upload: 'Upload Settings',
85-
internet_search: 'Internet Search',
85+
internet_search: 'Search',
8686
document_retrieval: 'Document Retrieval',
8787
feature_visibility: 'Feature Visibility',
88-
large_model_tool: 'Large Model Tool',
89-
tool_invoked_model: 'Tool-invoked Model',
88+
large_model_tool: 'LLM Tool',
89+
tool_invoked_model: 'Caller Model',
9090
prompt_template: 'Prompt Template',
9191
mcp_service: 'MCP Server',
92-
built_in_large_model_tool: 'Built-in Large Model Tool',
93-
intent_recognition: 'Intent Recognition',
94-
intent_recognition_model: 'Intent Recognition Model',
95-
feature_visibility_deep_thought: 'Feature Visibility (Deep Thought)',
92+
built_in_large_model_tool: 'Built-in LLM Tool',
93+
intent_recognition: 'Intent Analysis',
94+
intent_recognition_model: 'Intent Analysis Model',
95+
feature_visibility_deep_thought: 'Feature Visibility (Deep Think)',
9696
generate_response: 'Generate Response',
9797
capability_extension: 'Capability Extension',
98-
workflow_configuration: 'Workflow Configuration'
98+
workflow_configuration: 'Workflow Configuration',
99+
executionStrategy: 'Execution Strategy',
100+
availableVariables: 'Available Variables',
101+
availableVariablesDesc: 'List of available variables',
102+
searchContext: 'Search Results Context',
103+
userQuery: 'User Query',
104+
chatHistory: 'Chat History',
105+
toolList: 'Tool List',
106+
webSources: 'Network Sources List',
107+
detectedIntent: 'Detected Intent',
108+
matchedDocs: 'Retrieved Documents'
99109
},
100110
mode: {
101111
deep_think: 'Deep Think',
102112
simple: 'Simple',
103113
workflow: 'External workflow'
104114
},
105115
hints: {
106-
system_prompt: 'Please enter the system prompt instructions'
116+
system_prompt: 'Please enter the system prompt instructions',
117+
searchExecutionStrategy:
118+
'The model determines whether to execute the process based on context, query intent, etc.',
119+
llmExecutionStrategy: 'Execute the process whether or not the model deems it necessary.'
120+
},
121+
options: {
122+
intelligentDecisionMaking: 'Intelligent Decision Making',
123+
alwaysExecute: 'Always Execute'
107124
}
108125
},
109126
connector: {
@@ -724,7 +741,7 @@ const page: App.I18n.Schema['translation']['page'] = {
724741
inferenceMode: 'Inference Mode'
725742
},
726743
options: {
727-
dialogModel: 'Dialog Model'
744+
dialogModel: 'Chat Model'
728745
},
729746
hints: {
730747
selectOrInputModel: 'Select or input a model',

web/src/locales/langs/zh-cn/page.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,31 @@ const page: App.I18n.Schema['translation']['page'] = {
9090
feature_visibility_deep_thought: '功能可见性(深度思考)',
9191
generate_response: '生成回答',
9292
capability_extension: '能力扩展',
93-
workflow_configuration: '流程配置'
93+
workflow_configuration: '流程配置',
94+
executionStrategy: '执行策略',
95+
availableVariables: '可用变量',
96+
availableVariablesDesc: '可用的变量',
97+
searchContext: '搜索结果上下文',
98+
userQuery: '用户查询内容',
99+
chatHistory: '对话历史',
100+
toolList: '工具列表',
101+
webSources: '网络来源列表',
102+
detectedIntent: '识别到的意图',
103+
matchedDocs: '匹配到的文档'
94104
},
95105
mode: {
96106
deep_think: '深度思考',
97107
simple: '简单模式',
98108
workflow: '外部工作流'
99109
},
100110
hints: {
101-
system_prompt: '请输入系统提示词'
111+
system_prompt: '请输入系统提示词',
112+
searchExecutionStrategy: '由模型根据上下文、查询意图等判断是否执行该流程。',
113+
llmExecutionStrategy: '无论模型是否认为必要,都执行该流程。'
114+
},
115+
options: {
116+
intelligentDecisionMaking: '智能决策',
117+
alwaysExecute: '总是执行'
102118
}
103119
},
104120
connector: {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Flex, Popover } from 'antd';
2+
import { Info } from 'lucide-react';
3+
import type { FC } from 'react';
4+
5+
interface AvailableVariableProps {
6+
readonly type: 'answering_model' | 'caller_model' | 'intent_analysis_model' | 'picking_doc_model';
7+
}
8+
9+
const AvailableVariable: FC<AvailableVariableProps> = props => {
10+
const { type } = props;
11+
const { t } = useTranslation();
12+
13+
const variables: Record<AvailableVariableProps['type'], string[]> = {
14+
answering_model: [
15+
`{{.context}} ${t('page.assistant.labels.searchContext')}`,
16+
`{{.query}} ${t('page.assistant.labels.userQuery')}`
17+
],
18+
caller_model: [],
19+
intent_analysis_model: [
20+
`{{.history}} ${t('page.assistant.labels.chatHistory')}`,
21+
`{{.tool_list}} ${t('page.assistant.labels.toolList')}`,
22+
`{{.network_sources}} ${t('page.assistant.labels.webSources')}`,
23+
`{{.query}} ${t('page.assistant.labels.userQuery')}`
24+
],
25+
picking_doc_model: [
26+
`{{.query}} ${t('page.assistant.labels.userQuery')}`,
27+
`{{.intent}} ${t('page.assistant.labels.detectedIntent')}`,
28+
`{{.docs}} ${t('page.assistant.labels.matchedDocs')}`
29+
]
30+
};
31+
32+
return (
33+
variables[type].length !== 0 && (
34+
<Popover
35+
title={t('page.assistant.labels.availableVariablesDesc')}
36+
content={
37+
<Flex
38+
vertical
39+
gap={4}
40+
>
41+
{variables[type].map(variable => (
42+
<span key={variable}>{variable}</span>
43+
))}
44+
</Flex>
45+
}
46+
>
47+
<div className='inline-flex cursor-pointer items-center gap-1 pt-1'>
48+
<span>{t('page.assistant.labels.availableVariables')}</span>
49+
50+
<Info className='size-4' />
51+
</div>
52+
</Popover>
53+
)
54+
);
55+
};
56+
57+
export default AvailableVariable;

web/src/pages/ai-assistant/modules/DeepThink.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const DeepThink = (props: DeepThinkProps) => {
1919
>
2020
<ModelSelect
2121
modelType='intent_analysis_model'
22+
namePrefix={['config', 'intent_analysis_model']}
2223
providers={providers}
2324
/>
2425
</Form.Item>

web/src/pages/ai-assistant/modules/EditForm.tsx

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ import { DatasourceConfig } from './DatasourceConfig';
1212
import { MCPConfig } from './MCPConfig';
1313
import { DeepThink } from './DeepThink';
1414
import { formatESSearchResult } from '@/service/request/es';
15-
import ModelSelect from './ModelSelect';
15+
import ModelSelect, { DefaultPromptTemplates } from './ModelSelect';
1616
import { ToolsConfig } from './ToolsConfig';
1717
import { getUUID } from '@/utils/common';
1818
import { Tags } from '@/components/common/tags';
1919
import { getAssistantCategory } from '@/service/api/assistant';
2020
import { UploadConfig } from './UploadConfig';
2121
import classNames from 'classnames';
22+
import AvailableVariable from './AvailableVariable';
2223

2324
interface AssistantFormProps {
2425
initialValues: any;
@@ -91,7 +92,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
9192
}, []);
9293
const { defaultRequiredRule, formRules } = useFormRules();
9394

94-
const [showAdvanced, setShowAdvanced] = useState(true);
95+
const [showAdvanced, setShowAdvanced] = useState(false);
9596
const {
9697
data: result,
9798
run,
@@ -184,6 +185,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
184185
return (
185186
<Collapse
186187
className='mb-4 w-150'
188+
defaultActiveKey='intent-recognition'
187189
items={[
188190
{
189191
key: 'intent-recognition',
@@ -208,33 +210,40 @@ export const EditForm = memo((props: AssistantFormProps) => {
208210
key: 'internet-search',
209211
label: t('page.assistant.labels.internet_search'),
210212
extra: (
211-
<Form.Item
212-
className='mb-0! [&_*]:min-h-[unset]!'
213-
name={['datasource', 'enabled']}
213+
<div
214+
onClick={event => {
215+
event.stopPropagation();
216+
}}
214217
>
215-
<Switch size='small' />
216-
</Form.Item>
218+
<Form.Item
219+
className='mb-0! [&_*]:min-h-[unset]!'
220+
initialValue={false}
221+
name={['datasource', 'enabled']}
222+
>
223+
<Switch size='small' />
224+
</Form.Item>
225+
</div>
217226
),
218227
children: (
219228
<>
220229
{assistantMode === 'deep_think' && (
221230
<>
222231
<Form.Item
223232
className='mb-4! [&_.ant-form-item-control]:flex-[unset]!'
224-
extra='由模型根据上下文、查询意图等判断是否执行该流程'
233+
extra={t('page.assistant.hints.searchExecutionStrategy')}
225234
initialValue={false}
226-
label='执行策略'
235+
label={t('page.assistant.labels.executionStrategy')}
227236
layout='vertical'
228237
name={['config', 'pick_datasource']}
229238
>
230239
<Select
231240
options={[
232241
{
233-
label: '总是执行',
242+
label: t('page.assistant.options.alwaysExecute'),
234243
value: true
235244
},
236245
{
237-
label: '智能决策',
246+
label: t('page.assistant.options.intelligentDecisionMaking'),
238247
value: false
239248
}
240249
]}
@@ -243,12 +252,13 @@ export const EditForm = memo((props: AssistantFormProps) => {
243252

244253
<Form.Item
245254
className='[&_.ant-form-item-control]:flex-[unset]!'
246-
label='文档预选模型'
255+
label={t('page.settings.llm.picking_doc_model')}
247256
layout='vertical'
248257
name={['config', 'picking_doc_model']}
249258
>
250259
<ModelSelect
251260
modelType='picking_doc_model'
261+
namePrefix={['config', 'picking_doc_model']}
252262
providers={modelProviders}
253263
/>
254264
</Form.Item>
@@ -287,12 +297,19 @@ export const EditForm = memo((props: AssistantFormProps) => {
287297
key: 'large-model-tools',
288298
label: t('page.assistant.labels.large_model_tool'),
289299
extra: (
290-
<Form.Item
291-
className='mb-0! [&_*]:(min-h-[unset]!)'
292-
name={['mcp_servers', 'enabled']}
300+
<div
301+
onClick={event => {
302+
event.stopPropagation();
303+
}}
293304
>
294-
<Switch size='small' />
295-
</Form.Item>
305+
<Form.Item
306+
className='mb-0! [&_*]:(min-h-[unset]!)'
307+
initialValue={false}
308+
name={['mcp_servers', 'enabled']}
309+
>
310+
<Switch size='small' />
311+
</Form.Item>
312+
</div>
296313
),
297314
children: (
298315
<Form.Item
@@ -303,20 +320,20 @@ export const EditForm = memo((props: AssistantFormProps) => {
303320
{assistantMode === 'deep_think' && (
304321
<Form.Item
305322
className='mb-4! [&_.ant-form-item-control]:flex-[unset]!'
306-
extra='无论模型是否认为必要,都执行该流程'
323+
extra={t('page.assistant.hints.llmExecutionStrategy')}
307324
initialValue={false}
308-
label='执行策略'
325+
label={t('page.assistant.labels.executionStrategy')}
309326
layout='vertical'
310327
name={['config', 'pick_tools']}
311328
>
312329
<Select
313330
options={[
314331
{
315-
label: '总是执行',
332+
label: t('page.assistant.options.alwaysExecute'),
316333
value: true
317334
},
318335
{
319-
label: '智能决策',
336+
label: t('page.assistant.options.intelligentDecisionMaking'),
320337
value: false
321338
}
322339
]}
@@ -363,6 +380,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
363380
>
364381
<ModelSelect
365382
modelType='answering_model'
383+
namePrefix={['answering_model']}
366384
providers={modelProviders}
367385
/>
368386
</Form.Item>
@@ -506,6 +524,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
506524
>
507525
<ModelSelect
508526
modelType='answering_model'
527+
namePrefix={['answering_model']}
509528
providers={modelProviders}
510529
showTemplate={false}
511530
width='600px'
@@ -515,8 +534,10 @@ export const EditForm = memo((props: AssistantFormProps) => {
515534

516535
{assistantMode === 'simple' && (
517536
<Form.Item
537+
extra={<AvailableVariable type='answering_model' />}
538+
initialValue={DefaultPromptTemplates.answering_model}
518539
label={t('page.assistant.labels.role_prompt')}
519-
name={['prompt', 'template']}
540+
name={['answering_model', 'prompt', 'template']}
520541
>
521542
<Input.TextArea
522543
className='w-600px'

web/src/pages/ai-assistant/modules/MCPConfig.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Flex, Form, InputNumber, Select, Space, Switch } from 'antd';
1+
import { Flex, Form, InputNumber, Select, Switch } from 'antd';
22
import ModelSelect from './ModelSelect';
33
import type { ReactNode } from 'react';
44

@@ -36,6 +36,7 @@ export const MCPConfig = (props: MCPConfigProps) => {
3636

3737
<ModelSelect
3838
modelType='caller_model'
39+
namePrefix={['mcp_servers', 'model']}
3940
providers={props.modelProviders}
4041
value={value.model}
4142
width='100%'

web/src/pages/ai-assistant/modules/ModelSelect.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import InfiniIcon from '@/components/common/icon';
55
import { getLocale } from '@/store/slice/app';
66
import { Form, Input } from 'antd';
77
import { getServer } from '@/store/slice/server';
8+
import AvailableVariable from './AvailableVariable';
89

910
const DefaultModelSettings = {
1011
temperature: 0.7,
@@ -14,7 +15,7 @@ const DefaultModelSettings = {
1415
max_tokens: 4000
1516
};
1617

17-
const DefaultPromptTemplates = {
18+
export const DefaultPromptTemplates = {
1819
answering_model: `You are a helpful AI assistant.
1920
You will be given a conversation below and a follow-up question.
2021
@@ -111,7 +112,7 @@ Wrap the JSON result in <JSON></JSON> tags.
111112
};
112113

113114
export default (props: any) => {
114-
const { value: propsValue, onChange, providers = [], width, modelType, showTemplate = true } = props;
115+
const { value: propsValue, onChange, providers = [], width, modelType, showTemplate = true, namePrefix = [] } = props;
115116
let defaultPromptTpl = '';
116117
if (DefaultPromptTemplates[modelType]) {
117118
defaultPromptTpl = DefaultPromptTemplates[modelType];
@@ -289,10 +290,11 @@ export default (props: any) => {
289290
{showTemplate && (
290291
<Form.Item
291292
className='mb-0! mt-4!'
293+
help={<AvailableVariable type={modelType} />}
292294
initialValue={defaultPromptTpl}
293295
label={t('page.assistant.labels.prompt_template')}
294296
layout='vertical'
295-
name={['prompt', 'template']}
297+
name={[...namePrefix, 'prompt', 'template']}
296298
>
297299
<Input.TextArea rows={6} />
298300
</Form.Item>

0 commit comments

Comments
 (0)