fix(dataset, next-chats): Fix data form data acquisition logic And Optimize the chat settings interface and add language selection (#9629)

### What problem does this PR solve?

fix(dataset): data form data acquisition logic
fix(next-chats): Optimize the chat settings interface and add language
selection

- Replace form.formControl.trigger with form.trigger
- Use form.getValues() instead of form.formState.values
- Add language selection to support multiple languages
- Add default chat settings values
- Add new settings: icon, description, knowledge base ID, etc.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
This commit is contained in:
_Chenbing
2025-08-21 16:57:46 +08:00
committed by GitHub
parent 0bd58038a8
commit 0af57ff772
4 changed files with 46 additions and 5 deletions

View File

@ -187,8 +187,8 @@ export function GeneralForm() {
disabled={submitLoading}
onClick={() => {
(async () => {
let isValidate = await form.formControl.trigger('name');
const { name, description } = form.formState.values;
let isValidate = await form.trigger('name');
const { name, description } = form.getValues();
const avatar = avatarBase64Str;
if (isValidate) {

View File

@ -14,6 +14,7 @@ import {
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import { useTranslate } from '@/hooks/common-hooks';
import { useFormContext } from 'react-hook-form';
@ -21,6 +22,17 @@ export default function ChatBasicSetting() {
const { t } = useTranslate('chat');
const form = useFormContext();
const languageOptions = [
{ value: 'English', label: 'English' },
{ value: 'Chinese', label: 'Chinese' },
{ value: 'Spanish', label: 'Spanish' },
{ value: 'French', label: 'French' },
{ value: 'German', label: 'German' },
{ value: 'Japanese', label: 'Japanese' },
{ value: 'Korean', label: 'Korean' },
{ value: 'Vietnamese', label: 'Vietnamese' },
];
return (
<div className="space-y-8">
<FormField
@ -55,6 +67,30 @@ export default function ChatBasicSetting() {
</FormItem>
)}
/>
<FormField
control={form.control}
name="language"
render={({ field }) => (
<FormItem>
<FormLabel>{t('language')}</FormLabel>
<Select onValueChange={field.onChange} defaultValue={field.value}>
<FormControl>
<SelectTrigger>
<SelectValue placeholder={t('common.languagePlaceholder')} />
</SelectTrigger>
</FormControl>
<SelectContent>
{languageOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="description"

View File

@ -35,13 +35,18 @@ export function ChatSettings({ switchSettingVisible }: ChatSettingsProps) {
shouldUnregister: true,
defaultValues: {
name: '',
icon: [],
language: 'English',
description: '',
kb_ids: [],
prompt_config: {
quote: true,
keyword: false,
tts: false,
use_kg: false,
refine_multiturn: true,
system: '',
parameters: [],
},
top_n: 8,
vector_similarity_weight: 0.2,

View File

@ -34,11 +34,11 @@ export function useChatSettingSchema() {
name: z.string().min(1, { message: t('assistantNameMessage') }),
icon: z.array(z.instanceof(File)),
language: z.string().min(1, {
message: 'Username must be at least 2 characters.',
message: t('languageMessage'),
}),
description: z.string(),
description: z.string().optional(),
kb_ids: z.array(z.string()).min(0, {
message: 'Username must be at least 1 characters.',
message: t('knowledgeBasesMessage'),
}),
prompt_config: promptConfigSchema,
...rerankFormSchema,