mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00
feat: add base_url to ApiKeyModal (#167)
This commit is contained in:
parent
88eadb5c47
commit
7bae41c71f
@ -163,7 +163,7 @@ export interface IApiKeySavingParams {
|
|||||||
api_key: string;
|
api_key: string;
|
||||||
llm_name?: string;
|
llm_name?: string;
|
||||||
model_type?: string;
|
model_type?: string;
|
||||||
api_base?: string;
|
base_url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSaveApiKey = () => {
|
export const useSaveApiKey = () => {
|
||||||
|
@ -5,17 +5,20 @@ import { useEffect } from 'react';
|
|||||||
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
interface IProps extends Omit<IModalManagerChildrenProps, 'showModal'> {
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
initialValue: string;
|
initialValue: string;
|
||||||
onOk: (name: string) => void;
|
llmFactory: string;
|
||||||
|
onOk: (name: string, baseUrl: string) => void;
|
||||||
showModal?(): void;
|
showModal?(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FieldType = {
|
type FieldType = {
|
||||||
api_key?: string;
|
api_key?: string;
|
||||||
|
base_url?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ApiKeyModal = ({
|
const ApiKeyModal = ({
|
||||||
visible,
|
visible,
|
||||||
hideModal,
|
hideModal,
|
||||||
|
llmFactory,
|
||||||
loading,
|
loading,
|
||||||
initialValue,
|
initialValue,
|
||||||
onOk,
|
onOk,
|
||||||
@ -25,7 +28,7 @@ const ApiKeyModal = ({
|
|||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
const ret = await form.validateFields();
|
const ret = await form.validateFields();
|
||||||
|
|
||||||
return onOk(ret.api_key);
|
return onOk(ret.api_key, ret.base_url);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
@ -55,8 +58,8 @@ const ApiKeyModal = ({
|
|||||||
>
|
>
|
||||||
<Form
|
<Form
|
||||||
name="basic"
|
name="basic"
|
||||||
labelCol={{ span: 4 }}
|
labelCol={{ span: 6 }}
|
||||||
wrapperCol={{ span: 20 }}
|
wrapperCol={{ span: 18 }}
|
||||||
style={{ maxWidth: 600 }}
|
style={{ maxWidth: 600 }}
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
onFinishFailed={onFinishFailed}
|
onFinishFailed={onFinishFailed}
|
||||||
@ -71,6 +74,16 @@ const ApiKeyModal = ({
|
|||||||
>
|
>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{llmFactory === 'OpenAI' && (
|
||||||
|
<Form.Item<FieldType>
|
||||||
|
label="Base-Url"
|
||||||
|
name="base_url"
|
||||||
|
tooltip="The API key can be obtained by registering the corresponding LLM supplier."
|
||||||
|
rules={[{ required: true, message: 'Please input base url!' }]}
|
||||||
|
>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -28,8 +28,12 @@ export const useSubmitApiKey = () => {
|
|||||||
} = useSetModalState();
|
} = useSetModalState();
|
||||||
|
|
||||||
const onApiKeySavingOk = useCallback(
|
const onApiKeySavingOk = useCallback(
|
||||||
async (apiKey: string) => {
|
async (apiKey: string, baseUrl: string) => {
|
||||||
const ret = await saveApiKey({ ...savingParams, api_key: apiKey });
|
const ret = await saveApiKey({
|
||||||
|
...savingParams,
|
||||||
|
api_key: apiKey,
|
||||||
|
base_url: baseUrl,
|
||||||
|
});
|
||||||
|
|
||||||
if (ret === 0) {
|
if (ret === 0) {
|
||||||
hideApiKeyModal();
|
hideApiKeyModal();
|
||||||
@ -53,6 +57,7 @@ export const useSubmitApiKey = () => {
|
|||||||
return {
|
return {
|
||||||
saveApiKeyLoading: loading,
|
saveApiKeyLoading: loading,
|
||||||
initialApiKey: '',
|
initialApiKey: '',
|
||||||
|
llmFactory: savingParams.llm_factory,
|
||||||
onApiKeySavingOk,
|
onApiKeySavingOk,
|
||||||
apiKeyVisible,
|
apiKeyVisible,
|
||||||
hideApiKeyModal,
|
hideApiKeyModal,
|
||||||
|
@ -120,6 +120,7 @@ const UserSettingModel = () => {
|
|||||||
const {
|
const {
|
||||||
saveApiKeyLoading,
|
saveApiKeyLoading,
|
||||||
initialApiKey,
|
initialApiKey,
|
||||||
|
llmFactory,
|
||||||
onApiKeySavingOk,
|
onApiKeySavingOk,
|
||||||
apiKeyVisible,
|
apiKeyVisible,
|
||||||
hideApiKeyModal,
|
hideApiKeyModal,
|
||||||
@ -215,6 +216,7 @@ const UserSettingModel = () => {
|
|||||||
loading={saveApiKeyLoading}
|
loading={saveApiKeyLoading}
|
||||||
initialValue={initialApiKey}
|
initialValue={initialApiKey}
|
||||||
onOk={onApiKeySavingOk}
|
onOk={onApiKeySavingOk}
|
||||||
|
llmFactory={llmFactory}
|
||||||
></ApiKeyModal>
|
></ApiKeyModal>
|
||||||
<SystemModelSettingModal
|
<SystemModelSettingModal
|
||||||
visible={systemSettingVisible}
|
visible={systemSettingVisible}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user