balibabu
commited on
Commit
·
8102819
1
Parent(s):
e1fe06a
fix: add group id field to ApiKeyModal #1353 (#1540)
Browse files### What problem does this PR solve?
fix: add group id field to ApiKeyModal #1353
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
web/src/pages/user-setting/interface.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export interface ApiKeyPostBody {
|
2 |
+
api_key: string;
|
3 |
+
base_url: string;
|
4 |
+
group_id?: string;
|
5 |
+
}
|
web/src/pages/user-setting/setting-model/api-key-modal/index.tsx
CHANGED
@@ -2,18 +2,20 @@ import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
|
2 |
import { useTranslate } from '@/hooks/commonHooks';
|
3 |
import { Form, Input, Modal } from 'antd';
|
4 |
import { useEffect } from 'react';
|
|
|
5 |
|
6 |
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
7 |
loading: boolean;
|
8 |
initialValue: string;
|
9 |
llmFactory: string;
|
10 |
-
onOk: (
|
11 |
showModal?(): void;
|
12 |
}
|
13 |
|
14 |
type FieldType = {
|
15 |
api_key?: string;
|
16 |
base_url?: string;
|
|
|
17 |
};
|
18 |
|
19 |
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
|
@@ -32,7 +34,7 @@ const ApiKeyModal = ({
|
|
32 |
const handleOk = async () => {
|
33 |
const ret = await form.validateFields();
|
34 |
|
35 |
-
return onOk(ret
|
36 |
};
|
37 |
|
38 |
useEffect(() => {
|
@@ -75,6 +77,11 @@ const ApiKeyModal = ({
|
|
75 |
<Input placeholder="https://api.openai.com/v1" />
|
76 |
</Form.Item>
|
77 |
)}
|
|
|
|
|
|
|
|
|
|
|
78 |
</Form>
|
79 |
</Modal>
|
80 |
);
|
|
|
2 |
import { useTranslate } from '@/hooks/commonHooks';
|
3 |
import { Form, Input, Modal } from 'antd';
|
4 |
import { useEffect } from 'react';
|
5 |
+
import { ApiKeyPostBody } from '../../interface';
|
6 |
|
7 |
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
8 |
loading: boolean;
|
9 |
initialValue: string;
|
10 |
llmFactory: string;
|
11 |
+
onOk: (postBody: ApiKeyPostBody) => void;
|
12 |
showModal?(): void;
|
13 |
}
|
14 |
|
15 |
type FieldType = {
|
16 |
api_key?: string;
|
17 |
base_url?: string;
|
18 |
+
group_id?: string;
|
19 |
};
|
20 |
|
21 |
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
|
|
|
34 |
const handleOk = async () => {
|
35 |
const ret = await form.validateFields();
|
36 |
|
37 |
+
return onOk(ret);
|
38 |
};
|
39 |
|
40 |
useEffect(() => {
|
|
|
77 |
<Input placeholder="https://api.openai.com/v1" />
|
78 |
</Form.Item>
|
79 |
)}
|
80 |
+
{llmFactory === 'Minimax' && (
|
81 |
+
<Form.Item<FieldType> label={'Group ID'} name="group_id">
|
82 |
+
<Input />
|
83 |
+
</Form.Item>
|
84 |
+
)}
|
85 |
</Form>
|
86 |
</Modal>
|
87 |
);
|
web/src/pages/user-setting/setting-model/hooks.ts
CHANGED
@@ -16,6 +16,7 @@ import {
|
|
16 |
} from '@/hooks/userSettingHook';
|
17 |
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
18 |
import { useCallback, useEffect, useState } from 'react';
|
|
|
19 |
|
20 |
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
21 |
|
@@ -31,11 +32,10 @@ export const useSubmitApiKey = () => {
|
|
31 |
} = useSetModalState();
|
32 |
|
33 |
const onApiKeySavingOk = useCallback(
|
34 |
-
async (
|
35 |
const ret = await saveApiKey({
|
36 |
...savingParams,
|
37 |
-
|
38 |
-
base_url: baseUrl,
|
39 |
});
|
40 |
|
41 |
if (ret === 0) {
|
|
|
16 |
} from '@/hooks/userSettingHook';
|
17 |
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
18 |
import { useCallback, useEffect, useState } from 'react';
|
19 |
+
import { ApiKeyPostBody } from '../interface';
|
20 |
|
21 |
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
22 |
|
|
|
32 |
} = useSetModalState();
|
33 |
|
34 |
const onApiKeySavingOk = useCallback(
|
35 |
+
async (postBody: ApiKeyPostBody) => {
|
36 |
const ret = await saveApiKey({
|
37 |
...savingParams,
|
38 |
+
...postBody,
|
|
|
39 |
});
|
40 |
|
41 |
if (ret === 0) {
|