forked from infiniflow/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add TestingForm infiniflow#3221 (infiniflow#3810)
### What problem does this PR solve? Feat: Add TestingForm infiniflow#3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
7 changed files
with
325 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client'; | ||
|
||
import * as SliderPrimitive from '@radix-ui/react-slider'; | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
const Slider = React.forwardRef< | ||
React.ElementRef<typeof SliderPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<SliderPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
'relative flex w-full touch-none select-none items-center', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary"> | ||
<SliderPrimitive.Range className="absolute h-full bg-primary" /> | ||
</SliderPrimitive.Track> | ||
<SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-colors-text-core-standard ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" /> | ||
</SliderPrimitive.Root> | ||
)); | ||
Slider.displayName = SliderPrimitive.Root.displayName; | ||
|
||
type SliderProps = Omit< | ||
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>, | ||
'onChange' | 'value' | ||
> & { onChange: (value: number) => void; value: number }; | ||
|
||
const FormSlider = React.forwardRef< | ||
React.ElementRef<typeof SliderPrimitive.Root>, | ||
SliderProps | ||
>(({ onChange, value, ...props }, ref) => ( | ||
<Slider | ||
ref={ref} | ||
{...props} | ||
value={[value]} | ||
onValueChange={(vals) => { | ||
onChange(vals[0]); | ||
}} | ||
></Slider> | ||
)); | ||
|
||
Slider.displayName = SliderPrimitive.Root.displayName; | ||
|
||
export { FormSlider, Slider }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as React from 'react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
|
||
const Textarea = React.forwardRef< | ||
HTMLTextAreaElement, | ||
React.ComponentProps<'textarea'> | ||
>(({ className, ...props }, ref) => { | ||
return ( | ||
<textarea | ||
className={cn( | ||
'flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', | ||
className, | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
); | ||
}); | ||
Textarea.displayName = 'Textarea'; | ||
|
||
export { Textarea }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,58 @@ | ||
import { Badge } from '@/components/ui/badge'; | ||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; | ||
import TestingForm from './testing-form'; | ||
|
||
const list = new Array(15).fill({ | ||
content: `Lorem ipsum odor amet, consectetuer adipiscing elit. Ullamcorper vulputate id laoreet malesuada commodo molestie. Lectus convallis class euismod; consequat in curabitur. Ablandit praesent inceptos nibh placerat lectus fringilla finibus. Hac vivamus id scelerisque et gravida nec ligula et non. Consectetur eu himenaeos eget felis quis habitant tellus. Tellus commodo inceptos litora habitant per himenaeos faucibus pretium. Gravida velit pretium amet purus rhoncus taciti. `, | ||
}); | ||
|
||
export default function RetrievalTesting() { | ||
return <div>Retrieval testing</div>; | ||
return ( | ||
<section className="flex divide-x border-l h-full"> | ||
<div className="p-4"> | ||
<TestingForm></TestingForm> | ||
</div> | ||
<div className="p-4 flex-1 "> | ||
<h2 className="text-3xl font-bold mb-8 px-[10%]"> | ||
15 Results from 3 files | ||
</h2> | ||
<section className="flex flex-col gap-4 overflow-auto h-[85vh] px-[10%]"> | ||
{list.map((x, idx) => ( | ||
<Card | ||
key={idx} | ||
className="bg-colors-background-neutral-weak border-colors-outline-neutral-strong" | ||
> | ||
<CardHeader> | ||
<CardTitle> | ||
<div className="flex gap-2 flex-wrap"> | ||
<Badge | ||
variant="outline" | ||
className="bg-colors-background-inverse-strong p-2 rounded-xl text-base" | ||
> | ||
混合相似度 45.88 | ||
</Badge> | ||
<Badge | ||
variant="outline" | ||
className="bg-colors-background-inverse-strong p-2 rounded-xl text-base" | ||
> | ||
关键词似度 45.88 | ||
</Badge> | ||
<Badge | ||
variant="outline" | ||
className="bg-colors-background-inverse-strong p-2 rounded-xl text-base" | ||
> | ||
向量相似度 45.88 | ||
</Badge> | ||
</div> | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<p className="text-colors-text-neutral-strong">{x.content}</p> | ||
</CardContent> | ||
</Card> | ||
))} | ||
</section> | ||
</div> | ||
</section> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
'use client'; | ||
|
||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { useForm } from 'react-hook-form'; | ||
import { z } from 'zod'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import { | ||
Form, | ||
FormControl, | ||
FormDescription, | ||
FormField, | ||
FormItem, | ||
FormLabel, | ||
FormMessage, | ||
} from '@/components/ui/form'; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from '@/components/ui/select'; | ||
import { FormSlider } from '@/components/ui/slider'; | ||
import { Textarea } from '@/components/ui/textarea'; | ||
|
||
const formSchema = z.object({ | ||
username: z.number().min(2, { | ||
message: 'Username must be at least 2 characters.', | ||
}), | ||
a: z.number().min(2, { | ||
message: 'Username must be at least 2 characters.', | ||
}), | ||
b: z.string().min(2, { | ||
message: 'Username must be at least 2 characters.', | ||
}), | ||
c: z.number().min(2, { | ||
message: 'Username must be at least 2 characters.', | ||
}), | ||
d: z.string().min(2, { | ||
message: 'Username must be at least 2 characters.', | ||
}), | ||
}); | ||
|
||
export default function TestingForm() { | ||
const form = useForm<z.infer<typeof formSchema>>({ | ||
resolver: zodResolver(formSchema), | ||
defaultValues: { | ||
username: 0, | ||
}, | ||
}); | ||
|
||
function onSubmit(values: z.infer<typeof formSchema>) { | ||
console.log(values); | ||
} | ||
|
||
return ( | ||
<Form {...form}> | ||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> | ||
<FormField | ||
control={form.control} | ||
name="username" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<FormControl> | ||
<FormSlider {...field}></FormSlider> | ||
</FormControl> | ||
<FormDescription> | ||
This is your public display name. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="a" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<FormControl> | ||
<FormSlider {...field}></FormSlider> | ||
</FormControl> | ||
<FormDescription> | ||
This is your public display name. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="b" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<Select onValueChange={field.onChange} defaultValue={field.value}> | ||
<FormControl> | ||
<SelectTrigger className="bg-colors-background-inverse-weak"> | ||
<SelectValue placeholder="Select a verified email to display" /> | ||
</SelectTrigger> | ||
</FormControl> | ||
<SelectContent> | ||
<SelectItem value="m@example.com">m@example.com</SelectItem> | ||
<SelectItem value="m@google.com">m@google.com</SelectItem> | ||
<SelectItem value="m@support.com">m@support.com</SelectItem> | ||
</SelectContent> | ||
</Select> | ||
<FormDescription> | ||
This is your public display name. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="c" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<FormControl> | ||
<FormSlider {...field}></FormSlider> | ||
</FormControl> | ||
<FormDescription> | ||
This is your public display name. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<FormField | ||
control={form.control} | ||
name="d" | ||
render={({ field }) => ( | ||
<FormItem> | ||
<FormLabel>Username</FormLabel> | ||
<FormControl> | ||
<Textarea | ||
{...field} | ||
className="bg-colors-background-inverse-weak" | ||
></Textarea> | ||
</FormControl> | ||
<FormDescription> | ||
This is your public display name. | ||
</FormDescription> | ||
<FormMessage /> | ||
</FormItem> | ||
)} | ||
/> | ||
<Button | ||
variant={'tertiary'} | ||
size={'sm'} | ||
type="submit" | ||
className="w-full" | ||
> | ||
Test | ||
</Button> | ||
</form> | ||
</Form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters