mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-01 17:32:07 +08:00
### 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)
This commit is contained in:
parent
00943dc04a
commit
baeedc699d
5
web/src/pages/user-setting/interface.ts
Normal file
5
web/src/pages/user-setting/interface.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface ApiKeyPostBody {
|
||||||
|
api_key: string;
|
||||||
|
base_url: string;
|
||||||
|
group_id?: string;
|
||||||
|
}
|
@ -2,18 +2,20 @@ import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
|||||||
import { useTranslate } from '@/hooks/commonHooks';
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { Form, Input, Modal } from 'antd';
|
import { Form, Input, Modal } from 'antd';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
import { ApiKeyPostBody } from '../../interface';
|
||||||
|
|
||||||
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
initialValue: string;
|
initialValue: string;
|
||||||
llmFactory: string;
|
llmFactory: string;
|
||||||
onOk: (name: string, baseUrl: string) => void;
|
onOk: (postBody: ApiKeyPostBody) => void;
|
||||||
showModal?(): void;
|
showModal?(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FieldType = {
|
type FieldType = {
|
||||||
api_key?: string;
|
api_key?: string;
|
||||||
base_url?: string;
|
base_url?: string;
|
||||||
|
group_id?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
|
const modelsWithBaseUrl = ['OpenAI', 'Azure-OpenAI'];
|
||||||
@ -32,7 +34,7 @@ const ApiKeyModal = ({
|
|||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
const ret = await form.validateFields();
|
const ret = await form.validateFields();
|
||||||
|
|
||||||
return onOk(ret.api_key, ret.base_url);
|
return onOk(ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -75,6 +77,11 @@ const ApiKeyModal = ({
|
|||||||
<Input placeholder="https://api.openai.com/v1" />
|
<Input placeholder="https://api.openai.com/v1" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
|
{llmFactory === 'Minimax' && (
|
||||||
|
<Form.Item<FieldType> label={'Group ID'} name="group_id">
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -16,6 +16,7 @@ import {
|
|||||||
} from '@/hooks/userSettingHook';
|
} from '@/hooks/userSettingHook';
|
||||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
import { ApiKeyPostBody } from '../interface';
|
||||||
|
|
||||||
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
type SavingParamsState = Omit<IApiKeySavingParams, 'api_key'>;
|
||||||
|
|
||||||
@ -31,11 +32,10 @@ export const useSubmitApiKey = () => {
|
|||||||
} = useSetModalState();
|
} = useSetModalState();
|
||||||
|
|
||||||
const onApiKeySavingOk = useCallback(
|
const onApiKeySavingOk = useCallback(
|
||||||
async (apiKey: string, baseUrl: string) => {
|
async (postBody: ApiKeyPostBody) => {
|
||||||
const ret = await saveApiKey({
|
const ret = await saveApiKey({
|
||||||
...savingParams,
|
...savingParams,
|
||||||
api_key: apiKey,
|
...postBody,
|
||||||
base_url: baseUrl,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ret === 0) {
|
if (ret === 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user