Files
ragflow/web/src/pages/next-chats/chat/app-settings/use-chat-setting-schema.tsx
balibabu 7235638607 Feat: Show multiple chat boxes #3221 (#9443)
### What problem does this PR solve?

Feat: Show multiple chat boxes #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
2025-08-13 15:59:51 +08:00

50 lines
1.5 KiB
TypeScript

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() {
const { t } = useTranslate('chat');
const promptConfigSchema = z.object({
quote: z.boolean(),
keyword: z.boolean(),
tts: z.boolean(),
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(),
}),
),
tavily_api_key: z.string().optional(),
});
const formSchema = z.object({
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.',
}),
description: z.string(),
kb_ids: z.array(z.string()).min(0, {
message: 'Username must be at least 1 characters.',
}),
prompt_config: promptConfigSchema,
...rerankFormSchema,
llm_setting: z.object(omit(LlmSettingSchema, 'llm_id')),
llm_id: z.string().optional(),
...vectorSimilarityWeightSchema,
...topnSchema,
});
return formSchema;
}