11'use client' ;
22
3- import { ModelSpec } from '@/api' ;
3+ import { ModelSpec , TitleGenerateRequestLanguageEnum } from '@/api' ;
44import { useCollectionContext } from '@/components/providers/collection-provider' ;
55import { Badge } from '@/components/ui/badge' ;
66import { Button } from '@/components/ui/button' ;
@@ -20,6 +20,8 @@ import {
2020 FormLabel ,
2121} from '@/components/ui/form' ;
2222import { Input } from '@/components/ui/input' ;
23+ import { Label } from '@/components/ui/label' ;
24+ import { RadioGroup , RadioGroupItem } from '@/components/ui/radio-group' ;
2325import {
2426 Select ,
2527 SelectContent ,
@@ -36,7 +38,7 @@ import { apiClient } from '@/lib/api/client';
3638import { cn , objectKeys } from '@/lib/utils' ;
3739import { zodResolver } from '@hookform/resolvers/zod' ;
3840import _ from 'lodash' ;
39- import { useTranslations } from 'next-intl' ;
41+ import { useLocale , useTranslations } from 'next-intl' ;
4042import Link from 'next/link' ;
4143import { useRouter } from 'next/navigation' ;
4244import { useCallback , useEffect , useState } from 'react' ;
@@ -66,6 +68,7 @@ const collectionSchema = z
6668 enable_vision : z . boolean ( ) ,
6769 completion : collectionModelSchema ,
6870 embedding : collectionModelSchema ,
71+ language : z . enum ( Object . values ( TitleGenerateRequestLanguageEnum ) ) ,
6972 } ) ,
7073 } )
7174 . refine (
@@ -97,30 +100,6 @@ const collectionSchema = z
97100
98101type FormValueType = z . infer < typeof collectionSchema > ;
99102
100- const defaultValues : FormValueType = {
101- title : '' ,
102- description : '' ,
103- type : 'document' ,
104- config : {
105- source : 'system' ,
106- enable_fulltext : true ,
107- enable_knowledge_graph : true ,
108- enable_vector : true ,
109- enable_summary : false ,
110- enable_vision : false ,
111- completion : {
112- custom_llm_provider : '' ,
113- model : '' ,
114- model_service_provider : '' ,
115- } ,
116- embedding : {
117- custom_llm_provider : '' ,
118- model : '' ,
119- model_service_provider : '' ,
120- } ,
121- } ,
122- } ;
123-
124103export type ProviderModel = {
125104 label ?: string ;
126105 name ?: string ;
@@ -136,6 +115,32 @@ export const CollectionForm = ({ action }: { action: 'add' | 'edit' }) => {
136115 const common_tips = useTranslations ( 'common.tips' ) ;
137116 const common_action = useTranslations ( 'common.action' ) ;
138117 const page_collections = useTranslations ( 'page_collections' ) ;
118+ const locale = useLocale ( ) ;
119+
120+ const defaultValues : FormValueType = {
121+ title : '' ,
122+ description : '' ,
123+ type : 'document' ,
124+ config : {
125+ source : 'system' ,
126+ enable_fulltext : true ,
127+ enable_knowledge_graph : true ,
128+ enable_vector : true ,
129+ enable_summary : false ,
130+ enable_vision : false ,
131+ completion : {
132+ custom_llm_provider : '' ,
133+ model : '' ,
134+ model_service_provider : '' ,
135+ } ,
136+ embedding : {
137+ custom_llm_provider : '' ,
138+ model : '' ,
139+ model_service_provider : '' ,
140+ } ,
141+ language : locale ,
142+ } ,
143+ } ;
139144
140145 const CollectionConfigIndexTypes = {
141146 'config.enable_vector' : {
@@ -372,6 +377,32 @@ export const CollectionForm = ({ action }: { action: 'add' | 'edit' }) => {
372377 </ FormItem >
373378 ) }
374379 />
380+
381+ < FormField
382+ control = { form . control }
383+ name = "config.language"
384+ render = { ( { field } ) => (
385+ < FormItem >
386+ < FormLabel > { page_collections ( 'language' ) } </ FormLabel >
387+ < FormControl >
388+ < RadioGroup
389+ value = { field . value }
390+ onValueChange = { field . onChange }
391+ className = "mt-2 flex flex-row gap-4 items-center"
392+ >
393+ < Label >
394+ < RadioGroupItem value = "zh-CN" />
395+ { page_collections ( 'language_zh_CN' ) }
396+ </ Label >
397+ < Label >
398+ < RadioGroupItem value = "en-US" />
399+ { page_collections ( 'language_en_US' ) }
400+ </ Label >
401+ </ RadioGroup >
402+ </ FormControl >
403+ </ FormItem >
404+ ) }
405+ />
375406 </ CardContent >
376407 </ Card >
377408
0 commit comments