mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-31 15:45:08 +08:00
### What problem does this PR solve? Refactor: Refactor FishAudioModal and BedrockModal using shadcn. #1036 ### Type of change - [x] Refactoring
This commit is contained in:
@ -1,16 +1,17 @@
|
|||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { SelectWithSearch } from '@/components/originui/select-with-search';
|
||||||
|
import { RAGFlowFormItem } from '@/components/ragflow-form';
|
||||||
|
import { ButtonLoading } from '@/components/ui/button';
|
||||||
|
import { Form } from '@/components/ui/form';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Modal } from '@/components/ui/modal/modal';
|
||||||
|
import { Segmented } from '@/components/ui/segmented';
|
||||||
|
import { useCommonTranslation, useTranslate } from '@/hooks/common-hooks';
|
||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||||
import {
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
Form,
|
import { useMemo } from 'react';
|
||||||
Input,
|
import { useForm, useWatch } from 'react-hook-form';
|
||||||
InputNumber,
|
import { z } from 'zod';
|
||||||
Modal,
|
|
||||||
Segmented,
|
|
||||||
Select,
|
|
||||||
Typography,
|
|
||||||
} from 'antd';
|
|
||||||
import { useMemo, useState } from 'react';
|
|
||||||
import { LLMHeader } from '../../components/llm-header';
|
import { LLMHeader } from '../../components/llm-header';
|
||||||
import { BedrockRegionList } from '../../constant';
|
import { BedrockRegionList } from '../../constant';
|
||||||
|
|
||||||
@ -22,30 +23,84 @@ type FieldType = IAddLlmRequestBody & {
|
|||||||
aws_role_arn?: string;
|
aws_role_arn?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { Option } = Select;
|
|
||||||
const { Text } = Typography;
|
|
||||||
|
|
||||||
const BedrockModal = ({
|
const BedrockModal = ({
|
||||||
visible,
|
visible = false,
|
||||||
hideModal,
|
hideModal,
|
||||||
onOk,
|
onOk,
|
||||||
loading,
|
loading,
|
||||||
llmFactory,
|
llmFactory,
|
||||||
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
||||||
const [form] = Form.useForm<FieldType>();
|
|
||||||
const [authMode, setAuthMode] =
|
|
||||||
useState<FieldType['auth_mode']>('access_key_secret');
|
|
||||||
|
|
||||||
const { t } = useTranslate('setting');
|
const { t } = useTranslate('setting');
|
||||||
|
const { t: ct } = useCommonTranslation();
|
||||||
|
|
||||||
|
const FormSchema = z
|
||||||
|
.object({
|
||||||
|
model_type: z.enum(['chat', 'embedding'], {
|
||||||
|
required_error: t('modelTypeMessage'),
|
||||||
|
}),
|
||||||
|
llm_name: z.string().min(1, { message: t('bedrockModelNameMessage') }),
|
||||||
|
bedrock_region: z.string().min(1, { message: t('bedrockRegionMessage') }),
|
||||||
|
max_tokens: z
|
||||||
|
.number({
|
||||||
|
required_error: t('maxTokensMessage'),
|
||||||
|
invalid_type_error: t('maxTokensInvalidMessage'),
|
||||||
|
})
|
||||||
|
.nonnegative({ message: t('maxTokensMinMessage') }),
|
||||||
|
auth_mode: z
|
||||||
|
.enum(['access_key_secret', 'iam_role', 'assume_role'])
|
||||||
|
.default('access_key_secret'),
|
||||||
|
bedrock_ak: z.string().optional(),
|
||||||
|
bedrock_sk: z.string().optional(),
|
||||||
|
aws_role_arn: z.string().optional(),
|
||||||
|
})
|
||||||
|
.superRefine((data, ctx) => {
|
||||||
|
if (data.auth_mode === 'access_key_secret') {
|
||||||
|
if (!data.bedrock_ak || data.bedrock_ak.trim() === '') {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: t('bedrockAKMessage'),
|
||||||
|
path: ['bedrock_ak'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!data.bedrock_sk || data.bedrock_sk.trim() === '') {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: t('bedrockSKMessage'),
|
||||||
|
path: ['bedrock_sk'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.auth_mode === 'iam_role') {
|
||||||
|
if (!data.aws_role_arn || data.aws_role_arn.trim() === '') {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: t('awsRoleArnMessage'),
|
||||||
|
path: ['aws_role_arn'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = useForm<FieldType>({
|
||||||
|
resolver: zodResolver(FormSchema),
|
||||||
|
defaultValues: {
|
||||||
|
model_type: 'chat',
|
||||||
|
auth_mode: 'access_key_secret',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const authMode = useWatch({
|
||||||
|
control: form.control,
|
||||||
|
name: 'auth_mode',
|
||||||
|
});
|
||||||
|
|
||||||
const options = useMemo(
|
const options = useMemo(
|
||||||
() => BedrockRegionList.map((x) => ({ value: x, label: t(x) })),
|
() => BedrockRegionList.map((x) => ({ value: x, label: t(x) })),
|
||||||
[t],
|
[t],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async (values: FieldType) => {
|
||||||
const values = await form.validateFields();
|
|
||||||
|
|
||||||
// Only submit fields related to the active auth mode.
|
|
||||||
const cleanedValues: Record<string, any> = { ...values };
|
const cleanedValues: Record<string, any> = { ...values };
|
||||||
|
|
||||||
const fieldsByMode: Record<string, string[]> = {
|
const fieldsByMode: Record<string, string[]> = {
|
||||||
@ -75,145 +130,140 @@ const BedrockModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={
|
title={<LLMHeader name={llmFactory} />}
|
||||||
<div>
|
open={visible}
|
||||||
<LLMHeader name={llmFactory} />
|
onOpenChange={(open) => !open && hideModal?.()}
|
||||||
|
maskClosable={false}
|
||||||
|
footer={
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={hideModal}
|
||||||
|
className="px-2 py-1 border border-border-button rounded-md hover:bg-bg-card"
|
||||||
|
>
|
||||||
|
{t('cancel')}
|
||||||
|
</button>
|
||||||
|
<ButtonLoading type="submit" form="bedrock-form" loading={loading}>
|
||||||
|
{ct('ok')}
|
||||||
|
</ButtonLoading>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
open={visible}
|
|
||||||
onOk={handleOk}
|
|
||||||
onCancel={hideModal}
|
|
||||||
okButtonProps={{ loading }}
|
|
||||||
>
|
>
|
||||||
<Form
|
<Form {...form}>
|
||||||
name="basic"
|
<form
|
||||||
style={{ maxWidth: 600 }}
|
onSubmit={form.handleSubmit(handleOk)}
|
||||||
autoComplete="off"
|
className="space-y-6"
|
||||||
layout={'vertical'}
|
id="bedrock-form"
|
||||||
form={form}
|
|
||||||
>
|
|
||||||
<Form.Item<FieldType>
|
|
||||||
label={t('modelType')}
|
|
||||||
name="model_type"
|
|
||||||
initialValue={'chat'}
|
|
||||||
rules={[{ required: true, message: t('modelTypeMessage') }]}
|
|
||||||
>
|
>
|
||||||
<Select placeholder={t('modelTypeMessage')}>
|
<RAGFlowFormItem name="model_type" label={t('modelType')} required>
|
||||||
<Option value="chat">chat</Option>
|
{(field) => (
|
||||||
<Option value="embedding">embedding</Option>
|
<SelectWithSearch
|
||||||
</Select>
|
value={field.value}
|
||||||
</Form.Item>
|
onChange={field.onChange}
|
||||||
<Form.Item<FieldType>
|
options={[
|
||||||
label={t('modelName')}
|
{ label: 'chat', value: 'chat' },
|
||||||
name="llm_name"
|
{ label: 'embedding', value: 'embedding' },
|
||||||
rules={[{ required: true, message: t('bedrockModelNameMessage') }]}
|
]}
|
||||||
>
|
placeholder={t('modelTypeMessage')}
|
||||||
<Input placeholder={t('bedrockModelNameMessage')} />
|
/>
|
||||||
</Form.Item>
|
)}
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
|
||||||
{/* AWS Credential Mode Switch (AK/SK section only) */}
|
<RAGFlowFormItem name="llm_name" label={t('modelName')} required>
|
||||||
<Form.Item>
|
<Input placeholder={t('bedrockModelNameMessage')} />
|
||||||
<Segmented
|
</RAGFlowFormItem>
|
||||||
block
|
|
||||||
value={authMode}
|
|
||||||
onChange={(v) => {
|
|
||||||
const next = v as FieldType['auth_mode'];
|
|
||||||
setAuthMode(next);
|
|
||||||
// Clear non-active fields so they won't be validated/submitted by accident.
|
|
||||||
if (next !== 'access_key_secret') {
|
|
||||||
form.setFieldsValue({ bedrock_ak: '', bedrock_sk: '' } as any);
|
|
||||||
}
|
|
||||||
if (next !== 'iam_role') {
|
|
||||||
form.setFieldsValue({ aws_role_arn: '' } as any);
|
|
||||||
}
|
|
||||||
if (next !== 'assume_role') {
|
|
||||||
form.setFieldsValue({ role_arn: '' } as any);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
options={[
|
|
||||||
{
|
|
||||||
label: t('awsAuthModeAccessKeySecret'),
|
|
||||||
value: 'access_key_secret',
|
|
||||||
},
|
|
||||||
{ label: t('awsAuthModeIamRole'), value: 'iam_role' },
|
|
||||||
{ label: t('awsAuthModeAssumeRole'), value: 'assume_role' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
{authMode === 'access_key_secret' && (
|
<div className="mb-4">
|
||||||
<>
|
<RAGFlowFormItem name="auth_mode">
|
||||||
<Form.Item<FieldType>
|
{(field) => (
|
||||||
label={t('awsAccessKeyId')}
|
<Segmented
|
||||||
name="bedrock_ak"
|
value={field.value}
|
||||||
rules={[{ required: true, message: t('bedrockAKMessage') }]}
|
onChange={(value) => {
|
||||||
|
// Clear non-active fields so they won't be validated/submitted by accident.
|
||||||
|
if (value !== 'access_key_secret') {
|
||||||
|
form.setValue('bedrock_ak', '');
|
||||||
|
form.setValue('bedrock_sk', '');
|
||||||
|
}
|
||||||
|
if (value !== 'iam_role') {
|
||||||
|
form.setValue('aws_role_arn', '');
|
||||||
|
}
|
||||||
|
field.onChange(value);
|
||||||
|
}}
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
label: t('awsAuthModeAccessKeySecret'),
|
||||||
|
value: 'access_key_secret',
|
||||||
|
},
|
||||||
|
{ label: t('awsAuthModeIamRole'), value: 'iam_role' },
|
||||||
|
{ label: t('awsAuthModeAssumeRole'), value: 'assume_role' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{authMode === 'access_key_secret' && (
|
||||||
|
<>
|
||||||
|
<RAGFlowFormItem
|
||||||
|
name="bedrock_ak"
|
||||||
|
label={t('awsAccessKeyId')}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<Input placeholder={t('bedrockAKMessage')} />
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
<RAGFlowFormItem
|
||||||
|
name="bedrock_sk"
|
||||||
|
label={t('awsSecretAccessKey')}
|
||||||
|
required
|
||||||
|
>
|
||||||
|
<Input placeholder={t('bedrockSKMessage')} />
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{authMode === 'iam_role' && (
|
||||||
|
<RAGFlowFormItem
|
||||||
|
name="aws_role_arn"
|
||||||
|
label={t('awsRoleArn')}
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<Input placeholder={t('bedrockAKMessage')} />
|
<Input placeholder={t('awsRoleArnMessage')} />
|
||||||
</Form.Item>
|
</RAGFlowFormItem>
|
||||||
<Form.Item<FieldType>
|
)}
|
||||||
label={t('awsSecretAccessKey')}
|
|
||||||
name="bedrock_sk"
|
|
||||||
rules={[{ required: true, message: t('bedrockSKMessage') }]}
|
|
||||||
>
|
|
||||||
<Input placeholder={t('bedrockSKMessage')} />
|
|
||||||
</Form.Item>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{authMode === 'iam_role' && (
|
{authMode === 'assume_role' && (
|
||||||
<Form.Item<FieldType>
|
<div className="text-sm text-text-secondary mt-2 mb-4">
|
||||||
label={t('awsRoleArn')}
|
{t('awsAssumeRoleTip')}
|
||||||
name="aws_role_arn"
|
</div>
|
||||||
rules={[{ required: true, message: t('awsRoleArnMessage') }]}
|
)}
|
||||||
|
|
||||||
|
<RAGFlowFormItem
|
||||||
|
name="bedrock_region"
|
||||||
|
label={t('bedrockRegion')}
|
||||||
|
required
|
||||||
>
|
>
|
||||||
<Input placeholder={t('awsRoleArnMessage')} />
|
{(field) => (
|
||||||
</Form.Item>
|
<SelectWithSearch
|
||||||
)}
|
value={field.value}
|
||||||
|
onChange={field.onChange}
|
||||||
|
options={options}
|
||||||
|
placeholder={t('bedrockRegionMessage')}
|
||||||
|
allowClear
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</RAGFlowFormItem>
|
||||||
|
|
||||||
{authMode === 'assume_role' && (
|
<RAGFlowFormItem name="max_tokens" label={t('maxTokens')} required>
|
||||||
<Form.Item
|
{(field) => (
|
||||||
style={{ marginTop: -8, marginBottom: 16 }}
|
<Input
|
||||||
// keep layout consistent with other modes
|
type="number"
|
||||||
>
|
placeholder={t('maxTokensTip')}
|
||||||
<Text type="secondary">{t('awsAssumeRoleTip')}</Text>
|
value={field.value}
|
||||||
</Form.Item>
|
onChange={(e) => field.onChange(Number(e.target.value))}
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
<Form.Item<FieldType>
|
</RAGFlowFormItem>
|
||||||
label={t('bedrockRegion')}
|
</form>
|
||||||
name="bedrock_region"
|
|
||||||
rules={[{ required: true, message: t('bedrockRegionMessage') }]}
|
|
||||||
>
|
|
||||||
<Select
|
|
||||||
placeholder={t('bedrockRegionMessage')}
|
|
||||||
options={options}
|
|
||||||
allowClear
|
|
||||||
></Select>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item<FieldType>
|
|
||||||
label={t('maxTokens')}
|
|
||||||
name="max_tokens"
|
|
||||||
rules={[
|
|
||||||
{ required: true, message: t('maxTokensMessage') },
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
message: t('maxTokensInvalidMessage'),
|
|
||||||
},
|
|
||||||
({}) => ({
|
|
||||||
validator(_, value) {
|
|
||||||
if (value < 0) {
|
|
||||||
return Promise.reject(new Error(t('maxTokensMinMessage')));
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber
|
|
||||||
placeholder={t('maxTokensTip')}
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import {
|
||||||
|
DynamicForm,
|
||||||
|
FormFieldConfig,
|
||||||
|
FormFieldType,
|
||||||
|
} from '@/components/dynamic-form';
|
||||||
|
import { Modal } from '@/components/ui/modal/modal';
|
||||||
|
import { useCommonTranslation, useTranslate } from '@/hooks/common-hooks';
|
||||||
import { IModalProps } from '@/interfaces/common';
|
import { IModalProps } from '@/interfaces/common';
|
||||||
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
import { IAddLlmRequestBody } from '@/interfaces/request/llm';
|
||||||
import { Flex, Form, Input, InputNumber, Modal, Select, Space } from 'antd';
|
import { FieldValues } from 'react-hook-form';
|
||||||
import omit from 'lodash/omit';
|
|
||||||
import { LLMHeader } from '../../components/llm-header';
|
import { LLMHeader } from '../../components/llm-header';
|
||||||
|
|
||||||
type FieldType = IAddLlmRequestBody & {
|
|
||||||
fish_audio_ak: string;
|
|
||||||
fish_audio_refid: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const { Option } = Select;
|
|
||||||
|
|
||||||
const FishAudioModal = ({
|
const FishAudioModal = ({
|
||||||
visible,
|
visible,
|
||||||
hideModal,
|
hideModal,
|
||||||
@ -19,107 +17,106 @@ const FishAudioModal = ({
|
|||||||
loading,
|
loading,
|
||||||
llmFactory,
|
llmFactory,
|
||||||
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
}: IModalProps<IAddLlmRequestBody> & { llmFactory: string }) => {
|
||||||
const [form] = Form.useForm<FieldType>();
|
|
||||||
|
|
||||||
const { t } = useTranslate('setting');
|
const { t } = useTranslate('setting');
|
||||||
|
const { t: tc } = useCommonTranslation();
|
||||||
|
|
||||||
const handleOk = async () => {
|
const fields: FormFieldConfig[] = [
|
||||||
const values = await form.validateFields();
|
{
|
||||||
const modelType = values.model_type;
|
name: 'model_type',
|
||||||
|
label: t('modelType'),
|
||||||
|
type: FormFieldType.Select,
|
||||||
|
required: true,
|
||||||
|
options: [{ label: 'tts', value: 'tts' }],
|
||||||
|
defaultValue: 'tts',
|
||||||
|
validation: { message: t('modelTypeMessage') },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'llm_name',
|
||||||
|
label: t('modelName'),
|
||||||
|
type: FormFieldType.Text,
|
||||||
|
required: true,
|
||||||
|
placeholder: t('FishAudioModelNameMessage'),
|
||||||
|
validation: { message: t('FishAudioModelNameMessage') },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'fish_audio_ak',
|
||||||
|
label: t('addFishAudioAK'),
|
||||||
|
type: FormFieldType.Text,
|
||||||
|
required: true,
|
||||||
|
placeholder: t('FishAudioAKMessage'),
|
||||||
|
validation: { message: t('FishAudioAKMessage') },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'fish_audio_refid',
|
||||||
|
label: t('addFishAudioRefID'),
|
||||||
|
type: FormFieldType.Text,
|
||||||
|
required: true,
|
||||||
|
placeholder: t('FishAudioRefIDMessage'),
|
||||||
|
validation: { message: t('FishAudioRefIDMessage') },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'max_tokens',
|
||||||
|
label: t('maxTokens'),
|
||||||
|
type: FormFieldType.Number,
|
||||||
|
required: true,
|
||||||
|
placeholder: t('maxTokensTip'),
|
||||||
|
validation: {
|
||||||
|
min: 0,
|
||||||
|
message: t('maxTokensInvalidMessage'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const data = {
|
const handleOk = async (values?: FieldValues) => {
|
||||||
...omit(values),
|
if (!values) return;
|
||||||
model_type: modelType,
|
|
||||||
|
const data: Record<string, any> = {
|
||||||
llm_factory: llmFactory,
|
llm_factory: llmFactory,
|
||||||
max_tokens: values.max_tokens,
|
llm_name: values.llm_name as string,
|
||||||
|
model_type: values.model_type,
|
||||||
|
fish_audio_ak: values.fish_audio_ak,
|
||||||
|
fish_audio_refid: values.fish_audio_refid,
|
||||||
|
max_tokens: values.max_tokens as number,
|
||||||
};
|
};
|
||||||
console.info(data);
|
|
||||||
|
|
||||||
onOk?.(data);
|
console.info(data);
|
||||||
|
await onOk?.(data as IAddLlmRequestBody);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={<LLMHeader name={llmFactory} />}
|
title={<LLMHeader name={llmFactory} />}
|
||||||
open={visible}
|
open={visible || false}
|
||||||
onOk={handleOk}
|
onOpenChange={(open) => !open && hideModal?.()}
|
||||||
onCancel={hideModal}
|
maskClosable={false}
|
||||||
okButtonProps={{ loading }}
|
footerClassName="py-1"
|
||||||
footer={(originNode: React.ReactNode) => {
|
footer={<div className="py-0"></div>}
|
||||||
return (
|
|
||||||
<Flex justify={'space-between'}>
|
|
||||||
<a href={`https://fish.audio`} target="_blank" rel="noreferrer">
|
|
||||||
{t('FishAudioLink')}
|
|
||||||
</a>
|
|
||||||
<Space>{originNode}</Space>
|
|
||||||
</Flex>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
confirmLoading={loading}
|
|
||||||
>
|
>
|
||||||
<Form
|
<DynamicForm.Root
|
||||||
name="basic"
|
fields={fields}
|
||||||
style={{ maxWidth: 600 }}
|
onSubmit={(data) => console.log(data)}
|
||||||
autoComplete="off"
|
defaultValues={{ model_type: 'tts' }}
|
||||||
layout={'vertical'}
|
labelClassName="font-normal"
|
||||||
form={form}
|
|
||||||
>
|
>
|
||||||
<Form.Item<FieldType>
|
<div className="flex items-center justify-between w-full">
|
||||||
label={t('modelType')}
|
<a
|
||||||
name="model_type"
|
href="https://fish.audio"
|
||||||
initialValue={'tts'}
|
target="_blank"
|
||||||
rules={[{ required: true, message: t('modelTypeMessage') }]}
|
rel="noreferrer"
|
||||||
>
|
className="text-sm text-text-secondary hover:text-primary"
|
||||||
<Select placeholder={t('modelTypeMessage')}>
|
>
|
||||||
<Option value="tts">tts</Option>
|
{t('FishAudioLink')}
|
||||||
</Select>
|
</a>
|
||||||
</Form.Item>
|
<div className="flex gap-2">
|
||||||
<Form.Item<FieldType>
|
<DynamicForm.CancelButton handleCancel={() => hideModal?.()} />
|
||||||
label={t('modelName')}
|
<DynamicForm.SavingButton
|
||||||
name="llm_name"
|
submitLoading={loading || false}
|
||||||
rules={[{ required: true, message: t('FishAudioModelNameMessage') }]}
|
buttonText={tc('ok')}
|
||||||
>
|
submitFunc={(values: FieldValues) => handleOk(values)}
|
||||||
<Input placeholder={t('FishAudioModelNameMessage')} />
|
/>
|
||||||
</Form.Item>
|
</div>
|
||||||
<Form.Item<FieldType>
|
</div>
|
||||||
label={t('addFishAudioAK')}
|
</DynamicForm.Root>
|
||||||
name="fish_audio_ak"
|
|
||||||
rules={[{ required: true, message: t('FishAudioAKMessage') }]}
|
|
||||||
>
|
|
||||||
<Input placeholder={t('FishAudioAKMessage')} />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item<FieldType>
|
|
||||||
label={t('addFishAudioRefID')}
|
|
||||||
name="fish_audio_refid"
|
|
||||||
rules={[{ required: true, message: t('FishAudioRefIDMessage') }]}
|
|
||||||
>
|
|
||||||
<Input placeholder={t('FishAudioRefIDMessage')} />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item<FieldType>
|
|
||||||
label={t('maxTokens')}
|
|
||||||
name="max_tokens"
|
|
||||||
rules={[
|
|
||||||
{ required: true, message: t('maxTokensMessage') },
|
|
||||||
{
|
|
||||||
type: 'number',
|
|
||||||
message: t('maxTokensInvalidMessage'),
|
|
||||||
},
|
|
||||||
({}) => ({
|
|
||||||
validator(_, value) {
|
|
||||||
if (value < 0) {
|
|
||||||
return Promise.reject(new Error(t('maxTokensMinMessage')));
|
|
||||||
}
|
|
||||||
return Promise.resolve();
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<InputNumber
|
|
||||||
placeholder={t('maxTokensTip')}
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user