Merge pull request #927 from SuanmoSuanyangTechnology/feature/model_json_zy
feat(web): agent support reset model config
This commit is contained in:
@@ -174,4 +174,8 @@ export const getAppLogsUrl = (app_id: string) => `/apps/${app_id}/logs`
|
|||||||
// Get full conversation message history
|
// Get full conversation message history
|
||||||
export const getAppLogDetail = (app_id: string, conversation_id: string) => {
|
export const getAppLogDetail = (app_id: string, conversation_id: string) => {
|
||||||
return request.get(`/apps/${app_id}/logs/${conversation_id}`)
|
return request.get(`/apps/${app_id}/logs/${conversation_id}`)
|
||||||
|
}
|
||||||
|
// Reset agent model config to default
|
||||||
|
export const resetAppModelConfig = (app_id: string) => {
|
||||||
|
return request.get(`/apps/${app_id}/model/parameters/default`)
|
||||||
}
|
}
|
||||||
@@ -11,14 +11,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, useImperativeHandle, useState, useEffect } from 'react';
|
import { forwardRef, useImperativeHandle, useState, useEffect } from 'react';
|
||||||
import { Form, type SelectProps, Checkbox } from 'antd';
|
import { Form, type SelectProps, Checkbox, Button } from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import type { ModelConfig, ModelConfigModalRef, Config, Source } from '../types'
|
import type { ModelConfig, ModelConfigModalRef, Config, Source } from '../types'
|
||||||
import type { Model } from '@/views/ModelManagement/types'
|
import type { Model } from '@/views/ModelManagement/types'
|
||||||
import RbModal from '@/components/RbModal'
|
import RbModal from '@/components/RbModal'
|
||||||
import RbSlider from '@/components/RbSlider'
|
import RbSlider from '@/components/RbSlider'
|
||||||
import ModelSelect from '@/components/ModelSelect'
|
import ModelSelect from '@/components/ModelSelect'
|
||||||
|
import { resetAppModelConfig } from '@/api/application';
|
||||||
|
|
||||||
const FormItem = Form.Item;
|
const FormItem = Form.Item;
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
data,
|
data,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const { id } = useParams();
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [form] = Form.useForm<ModelConfig>();
|
const [form] = Form.useForm<ModelConfig>();
|
||||||
const [source, setSource] = useState<Source>('model')
|
const [source, setSource] = useState<Source>('model')
|
||||||
@@ -124,14 +127,23 @@ const ModelConfigModal = forwardRef<ModelConfigModalRef, ModelConfigModalProps>(
|
|||||||
form.setFieldsValue(rest)
|
form.setFieldsValue(rest)
|
||||||
}, [values?.default_model_config_id])
|
}, [values?.default_model_config_id])
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
if (!id) return
|
||||||
|
resetAppModelConfig(id).then((res) => {
|
||||||
|
const { deep_thinking: _, json_output: __, ...rest } = (res || {}) as Config['model_parameters']
|
||||||
|
form.setFieldsValue(rest)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RbModal
|
<RbModal
|
||||||
title={t('application.modelConfig')}
|
title={t('application.modelConfig')}
|
||||||
open={visible}
|
open={visible}
|
||||||
onCancel={handleClose}
|
onCancel={handleClose}
|
||||||
cancelText={t('application.resetDefault')}
|
footer={[
|
||||||
okText={t('application.apply')}
|
<Button onClick={handleReset}>{t('application.resetDefault')}</Button>,
|
||||||
onOk={handleSave}
|
<Button type="primary" onClick={handleSave}>{t('application.apply')}</Button>,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
|
|||||||
Reference in New Issue
Block a user