fix(web): agent model
This commit is contained in:
@@ -130,6 +130,7 @@ const Agent = forwardRef<AgentRef, { onFeaturesLoad?: (features: FeaturesConfigF
|
|||||||
* @param type - Source type (model or chat)
|
* @param type - Source type (model or chat)
|
||||||
*/
|
*/
|
||||||
const refresh = (vo: ModelConfig, type: Source) => {
|
const refresh = (vo: ModelConfig, type: Source) => {
|
||||||
|
const opening_statement = form.getFieldValue(['features', 'opening_statement'])
|
||||||
if (type === 'model') {
|
if (type === 'model') {
|
||||||
const { default_model_config_id, capability, ...rest } = vo
|
const { default_model_config_id, capability, ...rest } = vo
|
||||||
if (default_model_config_id !== values.default_model_config_id) {
|
if (default_model_config_id !== values.default_model_config_id) {
|
||||||
@@ -148,11 +149,18 @@ const Agent = forwardRef<AgentRef, { onFeaturesLoad?: (features: FeaturesConfigF
|
|||||||
model_parameters: {...rest}
|
model_parameters: {...rest}
|
||||||
})
|
})
|
||||||
if (default_model_config_id === values?.default_model_config_id) {
|
if (default_model_config_id === values?.default_model_config_id) {
|
||||||
|
const label = defaultModel?.id === default_model_config_id && defaultModel?.name ? defaultModel.name : vo.label || ''
|
||||||
setChatList([{
|
setChatList([{
|
||||||
label: defaultModel?.id === default_model_config_id && defaultModel?.name ? defaultModel.name : vo.label || '',
|
label: defaultModel?.id === default_model_config_id && defaultModel?.name ? defaultModel.name : vo.label || '',
|
||||||
model_config_id: default_model_config_id || '',
|
model_config_id: default_model_config_id || '',
|
||||||
model_parameters: {...rest},
|
model_parameters: {...rest},
|
||||||
list: []
|
list: label !== '' ? [{
|
||||||
|
role: 'assistant',
|
||||||
|
content: opening_statement?.statement,
|
||||||
|
meta_data: {
|
||||||
|
suggested_questions: opening_statement?.suggested_questions || []
|
||||||
|
}
|
||||||
|
}] : []
|
||||||
}])
|
}])
|
||||||
}
|
}
|
||||||
} else if (type === 'chat') {
|
} else if (type === 'chat') {
|
||||||
@@ -275,11 +283,18 @@ const Agent = forwardRef<AgentRef, { onFeaturesLoad?: (features: FeaturesConfigF
|
|||||||
if (values?.default_model_config_id && modelList.length > 0) {
|
if (values?.default_model_config_id && modelList.length > 0) {
|
||||||
const filterValue = modelList.find(item => item.id === values.default_model_config_id)
|
const filterValue = modelList.find(item => item.id === values.default_model_config_id)
|
||||||
setDefaultModel(filterValue as Model | null)
|
setDefaultModel(filterValue as Model | null)
|
||||||
|
const opening_statement = form.getFieldValue(['features', 'opening_statement'])
|
||||||
setChatList([{
|
setChatList([{
|
||||||
label: filterValue?.name || '',
|
label: filterValue?.name || '',
|
||||||
model_config_id: filterValue?.id || '',
|
model_config_id: filterValue?.id || '',
|
||||||
model_parameters: {...(filterValue?.config || {})} as unknown as ModelConfig,
|
model_parameters: {...(filterValue?.config || {})} as unknown as ModelConfig,
|
||||||
list: []
|
list: filterValue?.name ? [{
|
||||||
|
role: 'assistant',
|
||||||
|
content: opening_statement?.statement,
|
||||||
|
meta_data: {
|
||||||
|
suggested_questions: opening_statement?.suggested_questions || []
|
||||||
|
}
|
||||||
|
}] : []
|
||||||
}])
|
}])
|
||||||
form.setFieldValue('capability', filterValue?.capability)
|
form.setFieldValue('capability', filterValue?.capability)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
>
|
>
|
||||||
{source !== 'multi_agent' &&
|
{source !== 'multi_agent' &&
|
||||||
<ModelSelect
|
<ModelSelect
|
||||||
|
params={{type: 'llm,chat'}}
|
||||||
placeholder={t('common.pleaseSelect')}
|
placeholder={t('common.pleaseSelect')}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user