Feat: Fixed the issue where some fields in the chat configuration could not be displayed #3221 (#9430)

### What problem does this PR solve?

Feat: Fixed the issue where some fields in the chat configuration could
not be displayed #3221
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-08-13 10:26:26 +08:00
committed by GitHub
parent 421657f64b
commit 9098efb8aa
16 changed files with 227 additions and 110 deletions

View File

@ -1,5 +1,9 @@
import { LlmSettingSchema } from '@/components/llm-setting-items/next';
import { rerankFormSchema } from '@/components/rerank';
import { vectorSimilarityWeightSchema } from '@/components/similarity-slider';
import { topnSchema } from '@/components/top-n-item';
import { useTranslate } from '@/hooks/common-hooks';
import { omit } from 'lodash';
import { z } from 'zod';
export function useChatSettingSchema() {
@ -9,13 +13,17 @@ export function useChatSettingSchema() {
quote: z.boolean(),
keyword: z.boolean(),
tts: z.boolean(),
empty_response: z.string().min(1, {
message: t('emptyResponse'),
}),
prologue: z.string().min(1, {}),
empty_response: z.string().optional(),
prologue: z.string().optional(),
system: z.string().min(1, { message: t('systemMessage') }),
refine_multiturn: z.boolean(),
use_kg: z.boolean(),
parameters: z.array(
z.object({
key: z.string(),
optional: z.boolean(),
}),
),
});
const formSchema = z.object({
@ -29,10 +37,11 @@ export function useChatSettingSchema() {
message: 'Username must be at least 1 characters.',
}),
prompt_config: promptConfigSchema,
top_n: z.number(),
vector_similarity_weight: z.number(),
top_k: z.number(),
llm_setting: z.object(LlmSettingSchema),
...rerankFormSchema,
llm_setting: z.object(omit(LlmSettingSchema, 'llm_id')),
llm_id: z.string().optional(),
...vectorSimilarityWeightSchema,
...topnSchema,
});
return formSchema;