fix: Add Model Providers:Azure-OpenAI error #1402 (#1512)

### What problem does this PR solve?

fix: Add Model Providers:Azure-OpenAI error #1402
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu 2024-07-15 15:55:04 +08:00 committed by GitHub
parent c2693d2f46
commit fdc21ec853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 18 deletions

View File

@ -16,6 +16,8 @@ type FieldType = {
base_url?: string; base_url?: string;
}; };
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
const ApiKeyModal = ({ const ApiKeyModal = ({
visible, visible,
hideModal, hideModal,
@ -33,18 +35,6 @@ const ApiKeyModal = ({
return onOk(ret.api_key, ret.base_url); return onOk(ret.api_key, ret.base_url);
}; };
const handleCancel = () => {
hideModal();
};
const onFinish = (values: any) => {
console.log('Success:', values);
};
const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
useEffect(() => { useEffect(() => {
if (visible) { if (visible) {
form.setFieldValue('api_key', initialValue); form.setFieldValue('api_key', initialValue);
@ -56,7 +46,7 @@ const ApiKeyModal = ({
title={t('modify')} title={t('modify')}
open={visible} open={visible}
onOk={handleOk} onOk={handleOk}
onCancel={handleCancel} onCancel={hideModal}
okButtonProps={{ loading }} okButtonProps={{ loading }}
confirmLoading={loading} confirmLoading={loading}
> >
@ -65,8 +55,6 @@ const ApiKeyModal = ({
labelCol={{ span: 6 }} labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }} wrapperCol={{ span: 18 }}
style={{ maxWidth: 600 }} style={{ maxWidth: 600 }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off" autoComplete="off"
form={form} form={form}
> >
@ -78,7 +66,7 @@ const ApiKeyModal = ({
> >
<Input /> <Input />
</Form.Item> </Form.Item>
{llmFactory === 'OpenAI' && ( {modelsWithBaseUrl.some((x) => x === llmFactory) && (
<Form.Item<FieldType> <Form.Item<FieldType>
label={t('baseUrl')} label={t('baseUrl')}
name="base_url" name="base_url"

View File

@ -4,7 +4,11 @@ import { IAddLlmRequestBody } from '@/interfaces/request/llm';
import { Flex, Form, Input, Modal, Select, Space, Switch } from 'antd'; import { Flex, Form, Input, Modal, Select, Space, Switch } from 'antd';
import omit from 'lodash/omit'; import omit from 'lodash/omit';
type FieldType = IAddLlmRequestBody & { vision: boolean }; type FieldType = IAddLlmRequestBody & {
vision: boolean;
volc_ak: string;
volc_sk: string;
};
const { Option } = Select; const { Option } = Select;
@ -13,7 +17,7 @@ const VolcEngineModal = ({
hideModal, hideModal,
onOk, onOk,
loading, loading,
llmFactory llmFactory,
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => { }: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
const [form] = Form.useForm<FieldType>(); const [form] = Form.useForm<FieldType>();