Skip to content

Commit

Permalink
fix: Add Model Providers:Azure-OpenAI error #1402 (#1512)
Browse files Browse the repository at this point in the history
### 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)
  • Loading branch information
cike8899 authored Jul 15, 2024
1 parent c2693d2 commit fdc21ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
20 changes: 4 additions & 16 deletions web/src/pages/user-setting/setting-model/api-key-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type FieldType = {
base_url?: string;
};

const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];

const ApiKeyModal = ({
visible,
hideModal,
Expand All @@ -33,18 +35,6 @@ const ApiKeyModal = ({
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(() => {
if (visible) {
form.setFieldValue('api_key', initialValue);
Expand All @@ -56,7 +46,7 @@ const ApiKeyModal = ({
title={t('modify')}
open={visible}
onOk={handleOk}
onCancel={handleCancel}
onCancel={hideModal}
okButtonProps={{ loading }}
confirmLoading={loading}
>
Expand All @@ -65,8 +55,6 @@ const ApiKeyModal = ({
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
style={{ maxWidth: 600 }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
form={form}
>
Expand All @@ -78,7 +66,7 @@ const ApiKeyModal = ({
>
<Input />
</Form.Item>
{llmFactory === 'OpenAI' && (
{modelsWithBaseUrl.some((x) => x === llmFactory) && (
<Form.Item<FieldType>
label={t('baseUrl')}
name="base_url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { IAddLlmRequestBody } from '@/interfaces/request/llm';
import { Flex, Form, Input, Modal, Select, Space, Switch } from 'antd';
import omit from 'lodash/omit';

type FieldType = IAddLlmRequestBody & { vision: boolean };
type FieldType = IAddLlmRequestBody & {
vision: boolean;
volc_ak: string;
volc_sk: string;
};

const { Option } = Select;

Expand All @@ -13,7 +17,7 @@ const VolcEngineModal = ({
hideModal,
onOk,
loading,
llmFactory
llmFactory,
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
const [form] = Form.useForm<FieldType>();

Expand Down

0 comments on commit fdc21ec

Please sign in to comment.