mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-25 16:26:51 +08:00
### What problem does this PR solve? Refactor Datasets UI #3221. ### Type of change - [X] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useTestRetrieval } from '@/hooks/use-knowledge-request';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { TopTitle } from '../dataset-title';
|
||||
import TestingForm from './testing-form';
|
||||
@ -41,7 +39,7 @@ export default function RetrievalTesting() {
|
||||
description={` Update your knowledge base configuration here, particularly the chunk
|
||||
method.`}
|
||||
></TopTitle>
|
||||
<Button>Save as Preset</Button>
|
||||
{/* <Button>Save as Preset</Button> */}
|
||||
</section>
|
||||
{count === 1 ? (
|
||||
<section className="flex divide-x h-full">
|
||||
@ -50,9 +48,9 @@ export default function RetrievalTesting() {
|
||||
<span className="text-text-title font-semibold text-2xl">
|
||||
Test setting
|
||||
</span>
|
||||
<Button variant={'outline'} onClick={addCount}>
|
||||
{/* <Button variant={'outline'} onClick={addCount}>
|
||||
<Plus /> Add New Test
|
||||
</Button>
|
||||
</Button> */}
|
||||
</div>
|
||||
<TestingForm
|
||||
loading={loading}
|
||||
|
||||
@ -4,6 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useForm, useWatch } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { CrossLanguageItem } from '@/components/cross-language-item-ui';
|
||||
import { FormContainer } from '@/components/form-container';
|
||||
import {
|
||||
initialTopKValue,
|
||||
@ -30,7 +31,8 @@ import { Textarea } from '@/components/ui/textarea';
|
||||
import { UseKnowledgeGraphFormField } from '@/components/use-knowledge-graph-item';
|
||||
import { useTestRetrieval } from '@/hooks/use-knowledge-request';
|
||||
import { trim } from 'lodash';
|
||||
import { useEffect } from 'react';
|
||||
import { CirclePlay } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type TestingFormProps = Pick<
|
||||
@ -44,6 +46,7 @@ export default function TestingForm({
|
||||
setValues,
|
||||
}: TestingFormProps) {
|
||||
const { t } = useTranslation();
|
||||
const [cross_languages, setCrossLangArr] = useState<string[]>([]);
|
||||
|
||||
const formSchema = z.object({
|
||||
question: z.string().min(1, {
|
||||
@ -68,8 +71,9 @@ export default function TestingForm({
|
||||
const values = useWatch({ control: form.control });
|
||||
|
||||
useEffect(() => {
|
||||
setValues(values as Required<z.infer<typeof formSchema>>);
|
||||
}, [setValues, values]);
|
||||
// setValues(values as Required<z.infer<typeof formSchema>>);
|
||||
setValues({ ...values, cross_languages });
|
||||
}, [setValues, values, cross_languages]);
|
||||
|
||||
function onSubmit() {
|
||||
refetch();
|
||||
@ -85,6 +89,12 @@ export default function TestingForm({
|
||||
></SimilaritySliderFormField>
|
||||
<RerankFormFields></RerankFormFields>
|
||||
<UseKnowledgeGraphFormField name="use_kg"></UseKnowledgeGraphFormField>
|
||||
<CrossLanguageItem
|
||||
name={'cross_languages'}
|
||||
onChange={(valArr) => {
|
||||
setCrossLangArr(valArr);
|
||||
}}
|
||||
></CrossLanguageItem>
|
||||
</FormContainer>
|
||||
<FormField
|
||||
control={form.control}
|
||||
@ -103,13 +113,16 @@ export default function TestingForm({
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<ButtonLoading
|
||||
type="submit"
|
||||
disabled={!!!trim(question)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('knowledgeDetails.testingLabel')}
|
||||
</ButtonLoading>
|
||||
<div className="flex justify-end">
|
||||
<ButtonLoading
|
||||
type="submit"
|
||||
disabled={!!!trim(question)}
|
||||
loading={loading}
|
||||
>
|
||||
{!loading && <CirclePlay />}
|
||||
{t('knowledgeDetails.testingLabel')}
|
||||
</ButtonLoading>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user