balibabu commited on
Commit
f7ee6db
·
1 Parent(s): f335329

Feat: Add TestingForm #3221 (#3810)

Browse files

### What problem does this PR solve?

Feat: Add TestingForm #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)

web/package-lock.json CHANGED
@@ -23,6 +23,7 @@
23
  "@radix-ui/react-popover": "^1.1.2",
24
  "@radix-ui/react-select": "^2.1.2",
25
  "@radix-ui/react-separator": "^1.1.0",
 
26
  "@radix-ui/react-slot": "^1.1.0",
27
  "@radix-ui/react-switch": "^1.1.1",
28
  "@radix-ui/react-tabs": "^1.1.1",
@@ -4751,6 +4752,38 @@
4751
  }
4752
  }
4753
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4754
  "node_modules/@radix-ui/react-slot": {
4755
  "version": "1.1.0",
4756
  "resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.1.0.tgz",
 
23
  "@radix-ui/react-popover": "^1.1.2",
24
  "@radix-ui/react-select": "^2.1.2",
25
  "@radix-ui/react-separator": "^1.1.0",
26
+ "@radix-ui/react-slider": "^1.2.1",
27
  "@radix-ui/react-slot": "^1.1.0",
28
  "@radix-ui/react-switch": "^1.1.1",
29
  "@radix-ui/react-tabs": "^1.1.1",
 
4752
  }
4753
  }
4754
  },
4755
+ "node_modules/@radix-ui/react-slider": {
4756
+ "version": "1.2.1",
4757
+ "resolved": "https://registry.npmmirror.com/@radix-ui/react-slider/-/react-slider-1.2.1.tgz",
4758
+ "integrity": "sha512-bEzQoDW0XP+h/oGbutF5VMWJPAl/UU8IJjr7h02SOHDIIIxq+cep8nItVNoBV+OMmahCdqdF38FTpmXoqQUGvw==",
4759
+ "dependencies": {
4760
+ "@radix-ui/number": "1.1.0",
4761
+ "@radix-ui/primitive": "1.1.0",
4762
+ "@radix-ui/react-collection": "1.1.0",
4763
+ "@radix-ui/react-compose-refs": "1.1.0",
4764
+ "@radix-ui/react-context": "1.1.1",
4765
+ "@radix-ui/react-direction": "1.1.0",
4766
+ "@radix-ui/react-primitive": "2.0.0",
4767
+ "@radix-ui/react-use-controllable-state": "1.1.0",
4768
+ "@radix-ui/react-use-layout-effect": "1.1.0",
4769
+ "@radix-ui/react-use-previous": "1.1.0",
4770
+ "@radix-ui/react-use-size": "1.1.0"
4771
+ },
4772
+ "peerDependencies": {
4773
+ "@types/react": "*",
4774
+ "@types/react-dom": "*",
4775
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
4776
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
4777
+ },
4778
+ "peerDependenciesMeta": {
4779
+ "@types/react": {
4780
+ "optional": true
4781
+ },
4782
+ "@types/react-dom": {
4783
+ "optional": true
4784
+ }
4785
+ }
4786
+ },
4787
  "node_modules/@radix-ui/react-slot": {
4788
  "version": "1.1.0",
4789
  "resolved": "https://registry.npmmirror.com/@radix-ui/react-slot/-/react-slot-1.1.0.tgz",
web/package.json CHANGED
@@ -34,6 +34,7 @@
34
  "@radix-ui/react-popover": "^1.1.2",
35
  "@radix-ui/react-select": "^2.1.2",
36
  "@radix-ui/react-separator": "^1.1.0",
 
37
  "@radix-ui/react-slot": "^1.1.0",
38
  "@radix-ui/react-switch": "^1.1.1",
39
  "@radix-ui/react-tabs": "^1.1.1",
 
34
  "@radix-ui/react-popover": "^1.1.2",
35
  "@radix-ui/react-select": "^2.1.2",
36
  "@radix-ui/react-separator": "^1.1.0",
37
+ "@radix-ui/react-slider": "^1.2.1",
38
  "@radix-ui/react-slot": "^1.1.0",
39
  "@radix-ui/react-switch": "^1.1.1",
40
  "@radix-ui/react-tabs": "^1.1.1",
web/src/components/ui/slider.tsx ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import * as SliderPrimitive from '@radix-ui/react-slider';
4
+ import * as React from 'react';
5
+
6
+ import { cn } from '@/lib/utils';
7
+
8
+ const Slider = React.forwardRef<
9
+ React.ElementRef<typeof SliderPrimitive.Root>,
10
+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
11
+ >(({ className, ...props }, ref) => (
12
+ <SliderPrimitive.Root
13
+ ref={ref}
14
+ className={cn(
15
+ 'relative flex w-full touch-none select-none items-center',
16
+ className,
17
+ )}
18
+ {...props}
19
+ >
20
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
21
+ <SliderPrimitive.Range className="absolute h-full bg-primary" />
22
+ </SliderPrimitive.Track>
23
+ <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" />
24
+ </SliderPrimitive.Root>
25
+ ));
26
+ Slider.displayName = SliderPrimitive.Root.displayName;
27
+
28
+ type SliderProps = Omit<
29
+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>,
30
+ 'onChange' | 'value'
31
+ > & { onChange: (value: number) => void; value: number };
32
+
33
+ const FormSlider = React.forwardRef<
34
+ React.ElementRef<typeof SliderPrimitive.Root>,
35
+ SliderProps
36
+ >(({ onChange, value, ...props }, ref) => (
37
+ <Slider
38
+ ref={ref}
39
+ {...props}
40
+ value={[value]}
41
+ onValueChange={(vals) => {
42
+ onChange(vals[0]);
43
+ }}
44
+ ></Slider>
45
+ ));
46
+
47
+ Slider.displayName = SliderPrimitive.Root.displayName;
48
+
49
+ export { FormSlider, Slider };
web/src/components/ui/textarea.tsx ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as React from 'react';
2
+
3
+ import { cn } from '@/lib/utils';
4
+
5
+ const Textarea = React.forwardRef<
6
+ HTMLTextAreaElement,
7
+ React.ComponentProps<'textarea'>
8
+ >(({ className, ...props }, ref) => {
9
+ return (
10
+ <textarea
11
+ className={cn(
12
+ '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',
13
+ className,
14
+ )}
15
+ ref={ref}
16
+ {...props}
17
+ />
18
+ );
19
+ });
20
+ Textarea.displayName = 'Textarea';
21
+
22
+ export { Textarea };
web/src/pages/dataset/testing/index.tsx CHANGED
@@ -1,3 +1,58 @@
 
 
 
 
 
 
 
 
1
  export default function RetrievalTesting() {
2
- return <div>Retrieval testing</div>;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  }
 
1
+ import { Badge } from '@/components/ui/badge';
2
+ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
3
+ import TestingForm from './testing-form';
4
+
5
+ const list = new Array(15).fill({
6
+ 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. `,
7
+ });
8
+
9
  export default function RetrievalTesting() {
10
+ return (
11
+ <section className="flex divide-x border-l h-full">
12
+ <div className="p-4">
13
+ <TestingForm></TestingForm>
14
+ </div>
15
+ <div className="p-4 flex-1 ">
16
+ <h2 className="text-3xl font-bold mb-8 px-[10%]">
17
+ 15 Results from 3 files
18
+ </h2>
19
+ <section className="flex flex-col gap-4 overflow-auto h-[85vh] px-[10%]">
20
+ {list.map((x, idx) => (
21
+ <Card
22
+ key={idx}
23
+ className="bg-colors-background-neutral-weak border-colors-outline-neutral-strong"
24
+ >
25
+ <CardHeader>
26
+ <CardTitle>
27
+ <div className="flex gap-2 flex-wrap">
28
+ <Badge
29
+ variant="outline"
30
+ className="bg-colors-background-inverse-strong p-2 rounded-xl text-base"
31
+ >
32
+ 混合相似度 45.88
33
+ </Badge>
34
+ <Badge
35
+ variant="outline"
36
+ className="bg-colors-background-inverse-strong p-2 rounded-xl text-base"
37
+ >
38
+ 关键词似度 45.88
39
+ </Badge>
40
+ <Badge
41
+ variant="outline"
42
+ className="bg-colors-background-inverse-strong p-2 rounded-xl text-base"
43
+ >
44
+ 向量相似度 45.88
45
+ </Badge>
46
+ </div>
47
+ </CardTitle>
48
+ </CardHeader>
49
+ <CardContent>
50
+ <p className="text-colors-text-neutral-strong">{x.content}</p>
51
+ </CardContent>
52
+ </Card>
53
+ ))}
54
+ </section>
55
+ </div>
56
+ </section>
57
+ );
58
  }
web/src/pages/dataset/testing/testing-form.tsx ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { useForm } from 'react-hook-form';
5
+ import { z } from 'zod';
6
+
7
+ import { Button } from '@/components/ui/button';
8
+ import {
9
+ Form,
10
+ FormControl,
11
+ FormDescription,
12
+ FormField,
13
+ FormItem,
14
+ FormLabel,
15
+ FormMessage,
16
+ } from '@/components/ui/form';
17
+ import {
18
+ Select,
19
+ SelectContent,
20
+ SelectItem,
21
+ SelectTrigger,
22
+ SelectValue,
23
+ } from '@/components/ui/select';
24
+ import { FormSlider } from '@/components/ui/slider';
25
+ import { Textarea } from '@/components/ui/textarea';
26
+
27
+ const formSchema = z.object({
28
+ username: z.number().min(2, {
29
+ message: 'Username must be at least 2 characters.',
30
+ }),
31
+ a: z.number().min(2, {
32
+ message: 'Username must be at least 2 characters.',
33
+ }),
34
+ b: z.string().min(2, {
35
+ message: 'Username must be at least 2 characters.',
36
+ }),
37
+ c: z.number().min(2, {
38
+ message: 'Username must be at least 2 characters.',
39
+ }),
40
+ d: z.string().min(2, {
41
+ message: 'Username must be at least 2 characters.',
42
+ }),
43
+ });
44
+
45
+ export default function TestingForm() {
46
+ const form = useForm<z.infer<typeof formSchema>>({
47
+ resolver: zodResolver(formSchema),
48
+ defaultValues: {
49
+ username: 0,
50
+ },
51
+ });
52
+
53
+ function onSubmit(values: z.infer<typeof formSchema>) {
54
+ console.log(values);
55
+ }
56
+
57
+ return (
58
+ <Form {...form}>
59
+ <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
60
+ <FormField
61
+ control={form.control}
62
+ name="username"
63
+ render={({ field }) => (
64
+ <FormItem>
65
+ <FormLabel>Username</FormLabel>
66
+ <FormControl>
67
+ <FormSlider {...field}></FormSlider>
68
+ </FormControl>
69
+ <FormDescription>
70
+ This is your public display name.
71
+ </FormDescription>
72
+ <FormMessage />
73
+ </FormItem>
74
+ )}
75
+ />
76
+ <FormField
77
+ control={form.control}
78
+ name="a"
79
+ render={({ field }) => (
80
+ <FormItem>
81
+ <FormLabel>Username</FormLabel>
82
+ <FormControl>
83
+ <FormSlider {...field}></FormSlider>
84
+ </FormControl>
85
+ <FormDescription>
86
+ This is your public display name.
87
+ </FormDescription>
88
+ <FormMessage />
89
+ </FormItem>
90
+ )}
91
+ />
92
+ <FormField
93
+ control={form.control}
94
+ name="b"
95
+ render={({ field }) => (
96
+ <FormItem>
97
+ <FormLabel>Username</FormLabel>
98
+ <Select onValueChange={field.onChange} defaultValue={field.value}>
99
+ <FormControl>
100
+ <SelectTrigger className="bg-colors-background-inverse-weak">
101
+ <SelectValue placeholder="Select a verified email to display" />
102
+ </SelectTrigger>
103
+ </FormControl>
104
+ <SelectContent>
105
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
106
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
107
+ <SelectItem value="[email protected]">[email protected]</SelectItem>
108
+ </SelectContent>
109
+ </Select>
110
+ <FormDescription>
111
+ This is your public display name.
112
+ </FormDescription>
113
+ <FormMessage />
114
+ </FormItem>
115
+ )}
116
+ />
117
+ <FormField
118
+ control={form.control}
119
+ name="c"
120
+ render={({ field }) => (
121
+ <FormItem>
122
+ <FormLabel>Username</FormLabel>
123
+ <FormControl>
124
+ <FormSlider {...field}></FormSlider>
125
+ </FormControl>
126
+ <FormDescription>
127
+ This is your public display name.
128
+ </FormDescription>
129
+ <FormMessage />
130
+ </FormItem>
131
+ )}
132
+ />
133
+ <FormField
134
+ control={form.control}
135
+ name="d"
136
+ render={({ field }) => (
137
+ <FormItem>
138
+ <FormLabel>Username</FormLabel>
139
+ <FormControl>
140
+ <Textarea
141
+ {...field}
142
+ className="bg-colors-background-inverse-weak"
143
+ ></Textarea>
144
+ </FormControl>
145
+ <FormDescription>
146
+ This is your public display name.
147
+ </FormDescription>
148
+ <FormMessage />
149
+ </FormItem>
150
+ )}
151
+ />
152
+ <Button
153
+ variant={'tertiary'}
154
+ size={'sm'}
155
+ type="submit"
156
+ className="w-full"
157
+ >
158
+ Test
159
+ </Button>
160
+ </form>
161
+ </Form>
162
+ );
163
+ }
web/tailwind.css CHANGED
@@ -132,7 +132,7 @@
132
  @apply border-border;
133
  }
134
  body {
135
- @apply bg-background text-foreground;
136
  font-feature-settings:
137
  'rlig' 1,
138
  'calt' 1;
 
132
  @apply border-border;
133
  }
134
  body {
135
+ @apply bg-colors-background-neutral-standard text-foreground;
136
  font-feature-settings:
137
  'rlig' 1,
138
  'calt' 1;