Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions web/src/locales/langs/en-us/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,45 @@ const page: App.I18n.Schema['translation']['page'] = {
'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.',
type: 'Type',
upload: 'Upload Settings',
internet_search: 'Internet Search',
internet_search: 'Search',
document_retrieval: 'Document Retrieval',
feature_visibility: 'Feature Visibility',
large_model_tool: 'Large Model Tool',
tool_invoked_model: 'Tool-invoked Model',
large_model_tool: 'LLM Tool',
tool_invoked_model: 'Caller Model',
prompt_template: 'Prompt Template',
mcp_service: 'MCP Server',
built_in_large_model_tool: 'Built-in Large Model Tool',
intent_recognition: 'Intent Recognition',
intent_recognition_model: 'Intent Recognition Model',
feature_visibility_deep_thought: 'Feature Visibility (Deep Thought)',
built_in_large_model_tool: 'Built-in LLM Tool',
intent_recognition: 'Intent Analysis',
intent_recognition_model: 'Intent Analysis Model',
feature_visibility_deep_thought: 'Feature Visibility (Deep Think)',
generate_response: 'Generate Response',
capability_extension: 'Capability Extension',
workflow_configuration: 'Workflow Configuration'
workflow_configuration: 'Workflow Configuration',
executionStrategy: 'Execution Strategy',
availableVariables: 'Available Variables',
availableVariablesDesc: 'List of available variables',
searchContext: 'Search Results Context',
userQuery: 'User Query',
chatHistory: 'Chat History',
toolList: 'Tool List',
webSources: 'Network Sources List',
detectedIntent: 'Detected Intent',
matchedDocs: 'Retrieved Documents'
},
mode: {
deep_think: 'Deep Think',
simple: 'Simple',
workflow: 'External workflow'
},
hints: {
system_prompt: 'Please enter the system prompt instructions'
system_prompt: 'Please enter the system prompt instructions',
searchExecutionStrategy:
'The model determines whether to execute the process based on context, query intent, etc.',
llmExecutionStrategy: 'Execute the process whether or not the model deems it necessary.'
},
options: {
intelligentDecisionMaking: 'Intelligent Decision Making',
alwaysExecute: 'Always Execute'
}
},
connector: {
Expand Down Expand Up @@ -724,7 +741,7 @@ const page: App.I18n.Schema['translation']['page'] = {
inferenceMode: 'Inference Mode'
},
options: {
dialogModel: 'Dialog Model'
dialogModel: 'Chat Model'
},
hints: {
selectOrInputModel: 'Select or input a model',
Expand Down
20 changes: 18 additions & 2 deletions web/src/locales/langs/zh-cn/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,31 @@ const page: App.I18n.Schema['translation']['page'] = {
feature_visibility_deep_thought: '功能可见性(深度思考)',
generate_response: '生成回答',
capability_extension: '能力扩展',
workflow_configuration: '流程配置'
workflow_configuration: '流程配置',
executionStrategy: '执行策略',
availableVariables: '可用变量',
availableVariablesDesc: '可用的变量',
searchContext: '搜索结果上下文',
userQuery: '用户查询内容',
chatHistory: '对话历史',
toolList: '工具列表',
webSources: '网络来源列表',
detectedIntent: '识别到的意图',
matchedDocs: '匹配到的文档'
},
mode: {
deep_think: '深度思考',
simple: '简单模式',
workflow: '外部工作流'
},
hints: {
system_prompt: '请输入系统提示词'
system_prompt: '请输入系统提示词',
searchExecutionStrategy: '由模型根据上下文、查询意图等判断是否执行该流程。',
llmExecutionStrategy: '无论模型是否认为必要,都执行该流程。'
},
options: {
intelligentDecisionMaking: '智能决策',
alwaysExecute: '总是执行'
}
},
connector: {
Expand Down
57 changes: 57 additions & 0 deletions web/src/pages/ai-assistant/modules/AvailableVariable.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Flex, Popover } from 'antd';
import { Info } from 'lucide-react';
import type { FC } from 'react';

interface AvailableVariableProps {
readonly type: 'answering_model' | 'caller_model' | 'intent_analysis_model' | 'picking_doc_model';
}

const AvailableVariable: FC<AvailableVariableProps> = props => {
const { type } = props;
const { t } = useTranslation();

const variables: Record<AvailableVariableProps['type'], string[]> = {
answering_model: [
`{{.context}} ${t('page.assistant.labels.searchContext')}`,
`{{.query}} ${t('page.assistant.labels.userQuery')}`
],
caller_model: [],
intent_analysis_model: [
`{{.history}} ${t('page.assistant.labels.chatHistory')}`,
`{{.tool_list}} ${t('page.assistant.labels.toolList')}`,
`{{.network_sources}} ${t('page.assistant.labels.webSources')}`,
`{{.query}} ${t('page.assistant.labels.userQuery')}`
],
picking_doc_model: [
`{{.query}} ${t('page.assistant.labels.userQuery')}`,
`{{.intent}} ${t('page.assistant.labels.detectedIntent')}`,
`{{.docs}} ${t('page.assistant.labels.matchedDocs')}`
]
};

return (
variables[type].length !== 0 && (
<Popover
title={t('page.assistant.labels.availableVariablesDesc')}
content={
<Flex
vertical
gap={4}
>
{variables[type].map(variable => (
<span key={variable}>{variable}</span>
))}
</Flex>
}
>
<div className='inline-flex cursor-pointer items-center gap-1 pt-1'>
<span>{t('page.assistant.labels.availableVariables')}</span>

<Info className='size-4' />
</div>
</Popover>
)
);
};

export default AvailableVariable;
1 change: 1 addition & 0 deletions web/src/pages/ai-assistant/modules/DeepThink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const DeepThink = (props: DeepThinkProps) => {
>
<ModelSelect
modelType='intent_analysis_model'
namePrefix={['config', 'intent_analysis_model']}
providers={providers}
/>
</Form.Item>
Expand Down
65 changes: 43 additions & 22 deletions web/src/pages/ai-assistant/modules/EditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import { DatasourceConfig } from './DatasourceConfig';
import { MCPConfig } from './MCPConfig';
import { DeepThink } from './DeepThink';
import { formatESSearchResult } from '@/service/request/es';
import ModelSelect from './ModelSelect';
import ModelSelect, { DefaultPromptTemplates } from './ModelSelect';
import { ToolsConfig } from './ToolsConfig';
import { getUUID } from '@/utils/common';
import { Tags } from '@/components/common/tags';
import { getAssistantCategory } from '@/service/api/assistant';
import { UploadConfig } from './UploadConfig';
import classNames from 'classnames';
import AvailableVariable from './AvailableVariable';

interface AssistantFormProps {
initialValues: any;
Expand Down Expand Up @@ -91,7 +92,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
}, []);
const { defaultRequiredRule, formRules } = useFormRules();

const [showAdvanced, setShowAdvanced] = useState(true);
const [showAdvanced, setShowAdvanced] = useState(false);
const {
data: result,
run,
Expand Down Expand Up @@ -184,6 +185,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
return (
<Collapse
className='mb-4 w-150'
defaultActiveKey='intent-recognition'
items={[
{
key: 'intent-recognition',
Expand All @@ -208,33 +210,40 @@ export const EditForm = memo((props: AssistantFormProps) => {
key: 'internet-search',
label: t('page.assistant.labels.internet_search'),
extra: (
<Form.Item
className='mb-0! [&_*]:min-h-[unset]!'
name={['datasource', 'enabled']}
<div
onClick={event => {
event.stopPropagation();
}}
>
<Switch size='small' />
</Form.Item>
<Form.Item
className='mb-0! [&_*]:min-h-[unset]!'
initialValue={false}
name={['datasource', 'enabled']}
>
<Switch size='small' />
</Form.Item>
</div>
),
children: (
<>
{assistantMode === 'deep_think' && (
<>
<Form.Item
className='mb-4! [&_.ant-form-item-control]:flex-[unset]!'
extra='由模型根据上下文、查询意图等判断是否执行该流程'
extra={t('page.assistant.hints.searchExecutionStrategy')}
initialValue={false}
label='执行策略'
label={t('page.assistant.labels.executionStrategy')}
layout='vertical'
name={['config', 'pick_datasource']}
>
<Select
options={[
{
label: '总是执行',
label: t('page.assistant.options.alwaysExecute'),
value: true
},
{
label: '智能决策',
label: t('page.assistant.options.intelligentDecisionMaking'),
value: false
}
]}
Expand All @@ -243,12 +252,13 @@ export const EditForm = memo((props: AssistantFormProps) => {

<Form.Item
className='[&_.ant-form-item-control]:flex-[unset]!'
label='文档预选模型'
label={t('page.settings.llm.picking_doc_model')}
layout='vertical'
name={['config', 'picking_doc_model']}
>
<ModelSelect
modelType='picking_doc_model'
namePrefix={['config', 'picking_doc_model']}
providers={modelProviders}
/>
</Form.Item>
Expand Down Expand Up @@ -287,12 +297,19 @@ export const EditForm = memo((props: AssistantFormProps) => {
key: 'large-model-tools',
label: t('page.assistant.labels.large_model_tool'),
extra: (
<Form.Item
className='mb-0! [&_*]:(min-h-[unset]!)'
name={['mcp_servers', 'enabled']}
<div
onClick={event => {
event.stopPropagation();
}}
>
<Switch size='small' />
</Form.Item>
<Form.Item
className='mb-0! [&_*]:(min-h-[unset]!)'
initialValue={false}
name={['mcp_servers', 'enabled']}
>
<Switch size='small' />
</Form.Item>
</div>
),
children: (
<Form.Item
Expand All @@ -303,20 +320,20 @@ export const EditForm = memo((props: AssistantFormProps) => {
{assistantMode === 'deep_think' && (
<Form.Item
className='mb-4! [&_.ant-form-item-control]:flex-[unset]!'
extra='无论模型是否认为必要,都执行该流程'
extra={t('page.assistant.hints.llmExecutionStrategy')}
initialValue={false}
label='执行策略'
label={t('page.assistant.labels.executionStrategy')}
layout='vertical'
name={['config', 'pick_tools']}
>
<Select
options={[
{
label: '总是执行',
label: t('page.assistant.options.alwaysExecute'),
value: true
},
{
label: '智能决策',
label: t('page.assistant.options.intelligentDecisionMaking'),
value: false
}
]}
Expand Down Expand Up @@ -363,6 +380,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
>
<ModelSelect
modelType='answering_model'
namePrefix={['answering_model']}
providers={modelProviders}
/>
</Form.Item>
Expand Down Expand Up @@ -506,6 +524,7 @@ export const EditForm = memo((props: AssistantFormProps) => {
>
<ModelSelect
modelType='answering_model'
namePrefix={['answering_model']}
providers={modelProviders}
showTemplate={false}
width='600px'
Expand All @@ -515,8 +534,10 @@ export const EditForm = memo((props: AssistantFormProps) => {

{assistantMode === 'simple' && (
<Form.Item
extra={<AvailableVariable type='answering_model' />}
initialValue={DefaultPromptTemplates.answering_model}
label={t('page.assistant.labels.role_prompt')}
name={['prompt', 'template']}
name={['answering_model', 'prompt', 'template']}
>
<Input.TextArea
className='w-600px'
Expand Down
3 changes: 2 additions & 1 deletion web/src/pages/ai-assistant/modules/MCPConfig.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Flex, Form, InputNumber, Select, Space, Switch } from 'antd';
import { Flex, Form, InputNumber, Select, Switch } from 'antd';
import ModelSelect from './ModelSelect';
import type { ReactNode } from 'react';

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

<ModelSelect
modelType='caller_model'
namePrefix={['mcp_servers', 'model']}
providers={props.modelProviders}
value={value.model}
width='100%'
Expand Down
8 changes: 5 additions & 3 deletions web/src/pages/ai-assistant/modules/ModelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import InfiniIcon from '@/components/common/icon';
import { getLocale } from '@/store/slice/app';
import { Form, Input } from 'antd';
import { getServer } from '@/store/slice/server';
import AvailableVariable from './AvailableVariable';

const DefaultModelSettings = {
temperature: 0.7,
Expand All @@ -14,7 +15,7 @@ const DefaultModelSettings = {
max_tokens: 4000
};

const DefaultPromptTemplates = {
export const DefaultPromptTemplates = {
answering_model: `You are a helpful AI assistant.
You will be given a conversation below and a follow-up question.

Expand Down Expand Up @@ -111,7 +112,7 @@ Wrap the JSON result in <JSON></JSON> tags.
};

export default (props: any) => {
const { value: propsValue, onChange, providers = [], width, modelType, showTemplate = true } = props;
const { value: propsValue, onChange, providers = [], width, modelType, showTemplate = true, namePrefix = [] } = props;
let defaultPromptTpl = '';
if (DefaultPromptTemplates[modelType]) {
defaultPromptTpl = DefaultPromptTemplates[modelType];
Expand Down Expand Up @@ -289,10 +290,11 @@ export default (props: any) => {
{showTemplate && (
<Form.Item
className='mb-0! mt-4!'
help={<AvailableVariable type={modelType} />}
initialValue={defaultPromptTpl}
label={t('page.assistant.labels.prompt_template')}
layout='vertical'
name={['prompt', 'template']}
name={[...namePrefix, 'prompt', 'template']}
>
<Input.TextArea rows={6} />
</Form.Item>
Expand Down
Loading
Loading