diff --git a/web/src/components/cross-language-item-ui.tsx b/web/src/components/cross-language-item-ui.tsx new file mode 100644 index 000000000..3fbf5430d --- /dev/null +++ b/web/src/components/cross-language-item-ui.tsx @@ -0,0 +1,48 @@ +import { FormLabel } from '@/components/ui/form'; +import { MultiSelect } from '@/components/ui/multi-select'; +import { useTranslation } from 'react-i18next'; + +const Languages = [ + 'English', + 'Chinese', + 'Spanish', + 'French', + 'German', + 'Japanese', + 'Korean', +]; + +const options = Languages.map((x) => ({ label: x, value: x })); + +type CrossLanguageItemProps = { + name?: string | Array; + onChange: (arg: string[]) => void; +}; + +export const CrossLanguageItem = ({ + name = ['prompt_config', 'cross_languages'], + onChange = () => {}, +}: CrossLanguageItemProps) => { + const { t } = useTranslation(); + + return ( +
+
+ + {t('chat.crossLanguage')} + +
+ { + onChange(val); + }} + // defaultValue={field.value} + placeholder={t('fileManager.pleaseSelect')} + maxCount={100} + // {...field} + modalPopover + /> +
+ ); +}; diff --git a/web/src/components/delimiter-form-field.tsx b/web/src/components/delimiter-form-field.tsx index 479aa917c..cc1affd56 100644 --- a/web/src/components/delimiter-form-field.tsx +++ b/web/src/components/delimiter-form-field.tsx @@ -43,17 +43,33 @@ export function DelimiterFormField() { ( - - - {t('knowledgeDetails.delimiter')} - - - - - - - )} + render={({ field }) => { + if (typeof field.value === 'undefined') { + // default value set + form.setValue('parser_config.delimiter', '\n'); + } + return ( + +
+ + {t('knowledgeDetails.delimiter')} + +
+ + + +
+
+
+
+ +
+
+ ); + }} /> ); } diff --git a/web/src/components/edit-tag/index.less b/web/src/components/edit-tag/index.less index ef67d1023..1c4314cfb 100644 --- a/web/src/components/edit-tag/index.less +++ b/web/src/components/edit-tag/index.less @@ -2,14 +2,15 @@ display: flex; gap: 8px; flex-wrap: wrap; - width: 100%; + // width: 100%; margin-bottom: 8px; } .tag { max-width: 100%; margin: 0; - padding: 2px 20px 2px 4px; + padding: 2px 20px 0px 4px; + height: 26px; font-size: 14px; .textEllipsis(); position: relative; diff --git a/web/src/components/edit-tag/index.tsx b/web/src/components/edit-tag/index.tsx index 676ba7ff9..6a82351b3 100644 --- a/web/src/components/edit-tag/index.tsx +++ b/web/src/components/edit-tag/index.tsx @@ -74,7 +74,7 @@ const EditTag = ({ value = [], onChange }: EditTagsProps) => { }; return ( -
+
{Array.isArray(tagChild) && tagChild.length > 0 && ( { )} {inputVisible ? ( - +
+ +
) : ( - - - +
+ + + +
)}
); diff --git a/web/src/components/entity-types-form-field.tsx b/web/src/components/entity-types-form-field.tsx index 6cf3e364b..3a5de8ce5 100644 --- a/web/src/components/entity-types-form-field.tsx +++ b/web/src/components/entity-types-form-field.tsx @@ -24,12 +24,21 @@ export function EntityTypesFormField({ control={form.control} name={name} render={({ field }) => ( - - {t('entityTypes')} - - - - + +
+ + * {t('entityTypes')} + +
+ + + +
+
+
+
+ +
)} /> diff --git a/web/src/components/excel-to-html-form-field.tsx b/web/src/components/excel-to-html-form-field.tsx index 2e4ba1139..90fa5de81 100644 --- a/web/src/components/excel-to-html-form-field.tsx +++ b/web/src/components/excel-to-html-form-field.tsx @@ -17,18 +17,37 @@ export function ExcelToHtmlFormField() { ( - - {t('html4excel')} - - - - - - )} + render={({ field }) => { + if (typeof field.value === 'undefined') { + // default value set + form.setValue('parser_config.html4excel', false); + } + + return ( + +
+ + {t('html4excel')} + +
+ + + +
+
+
+
+ +
+
+ ); + }} /> ); } diff --git a/web/src/components/layout-recognize-form-field.tsx b/web/src/components/layout-recognize-form-field.tsx index 0c95ef660..50eccbffb 100644 --- a/web/src/components/layout-recognize-form-field.tsx +++ b/web/src/components/layout-recognize-form-field.tsx @@ -54,17 +54,37 @@ export function LayoutRecognizeFormField() { ( - - - {t('layoutRecognize')} - - - - - - - )} + render={({ field }) => { + if (typeof field.value === 'undefined') { + // default value set + form.setValue( + 'parser_config.layout_recognize', + form.formState.defaultValues?.parser_config?.layout_recognize ?? + 'DeepDOC', + ); + } + return ( + +
+ + {t('layoutRecognize')} + +
+ + + +
+
+
+
+ +
+
+ ); + }} /> ); } diff --git a/web/src/components/originui/input.tsx b/web/src/components/originui/input.tsx new file mode 100644 index 000000000..d8c125f91 --- /dev/null +++ b/web/src/components/originui/input.tsx @@ -0,0 +1,25 @@ +import * as React from 'react'; + +import { cn } from '@/lib/utils'; + +function Input({ className, type, ...props }: React.ComponentProps<'input'>) { + return ( + + ); +} + +export { Input }; diff --git a/web/src/components/page-rank-form-field.tsx b/web/src/components/page-rank-form-field.tsx index 4ce23d6fc..dce708b72 100644 --- a/web/src/components/page-rank-form-field.tsx +++ b/web/src/components/page-rank-form-field.tsx @@ -11,7 +11,7 @@ export function PageRankFormField() { tooltip={t('pageRankTip')} defaultValue={0} max={100} - min={1} + min={0} > ); } diff --git a/web/src/components/parse-configuration/graph-rag-form-fields.tsx b/web/src/components/parse-configuration/graph-rag-form-fields.tsx index 7448ca372..fddc65cf6 100644 --- a/web/src/components/parse-configuration/graph-rag-form-fields.tsx +++ b/web/src/components/parse-configuration/graph-rag-form-fields.tsx @@ -58,17 +58,27 @@ export function UseGraphRagFormField() { control={form.control} name="parser_config.graphrag.use_graphrag" render={({ field }) => ( - - - {t('useGraphRag')} - - - - - + +
+ + {t('useGraphRag')} + +
+ + + +
+
+
+
+ +
)} /> @@ -112,25 +122,33 @@ const GraphRagItems = ({ control={form.control} name="parser_config.graphrag.method" render={({ field }) => ( - -
, - )} - > - {t('graphRagMethod')} - - - - - + +
+
, + )} + > + {t('graphRagMethod')} + +
+ + + +
+ +
+
+ +
)} /> @@ -139,17 +157,27 @@ const GraphRagItems = ({ control={form.control} name="parser_config.graphrag.resolution" render={({ field }) => ( - - - {t('resolution')} - - - - - + +
+ + {t('resolution')} + +
+ + + +
+
+
+
+ +
)} /> @@ -158,17 +186,27 @@ const GraphRagItems = ({ control={form.control} name="parser_config.graphrag.community" render={({ field }) => ( - - - {t('community')} - - - - - + +
+ + {t('community')} + +
+ + + +
+
+
+
+ +
)} /> diff --git a/web/src/components/parse-configuration/raptor-form-fields-old.tsx b/web/src/components/parse-configuration/raptor-form-fields-old.tsx new file mode 100644 index 000000000..28cd79ced --- /dev/null +++ b/web/src/components/parse-configuration/raptor-form-fields-old.tsx @@ -0,0 +1,146 @@ +import { DocumentParserType } from '@/constants/knowledge'; +import { useTranslate } from '@/hooks/common-hooks'; +import random from 'lodash/random'; +import { Plus } from 'lucide-react'; +import { useCallback } from 'react'; +import { useFormContext, useWatch } from 'react-hook-form'; +import { SliderInputFormField } from '../slider-input-form-field'; +import { Button } from '../ui/button'; +import { + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from '../ui/form'; +import { Input } from '../ui/input'; +import { Switch } from '../ui/switch'; +import { Textarea } from '../ui/textarea'; + +export const excludedParseMethods = [ + DocumentParserType.Table, + DocumentParserType.Resume, + DocumentParserType.One, + DocumentParserType.Picture, + DocumentParserType.KnowledgeGraph, + DocumentParserType.Qa, + DocumentParserType.Tag, +]; + +export const showRaptorParseConfiguration = ( + parserId: DocumentParserType | undefined, +) => { + return !excludedParseMethods.some((x) => x === parserId); +}; + +export const excludedTagParseMethods = [ + DocumentParserType.Table, + DocumentParserType.KnowledgeGraph, + DocumentParserType.Tag, +]; + +export const showTagItems = (parserId: DocumentParserType) => { + return !excludedTagParseMethods.includes(parserId); +}; + +const UseRaptorField = 'parser_config.raptor.use_raptor'; +const RandomSeedField = 'parser_config.raptor.random_seed'; + +// The three types "table", "resume" and "one" do not display this configuration. + +const RaptorFormFields = () => { + const form = useFormContext(); + const { t } = useTranslate('knowledgeConfiguration'); + const useRaptor = useWatch({ name: UseRaptorField }); + + const handleGenerate = useCallback(() => { + form.setValue(RandomSeedField, random(10000)); + }, [form]); + + return ( + <> + ( + + {t('useRaptor')} + + + + + + )} + /> + {useRaptor && ( +
+ ( + + {t('prompt')} + +