Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -3,34 +3,163 @@ import gradio as gr
|
|
3 |
|
4 |
with gr.Blocks() as demo:
|
5 |
gr.Markdown('# vector_search')
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
with gr.Tab('search'):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
search_button.click(
|
31 |
fn=fn.search,
|
32 |
-
inputs=[
|
33 |
-
outputs=[
|
34 |
)
|
35 |
|
36 |
if __name__ == '__main__':
|
|
|
3 |
|
4 |
with gr.Blocks() as demo:
|
5 |
gr.Markdown('# vector_search')
|
6 |
+
info = gr.Markdown()
|
7 |
+
|
8 |
+
with gr.Tab('ddg'):
|
9 |
+
ddg_query = gr.Textbox(
|
10 |
+
lines=1,
|
11 |
+
label='Query',
|
12 |
+
interactive=True,
|
13 |
+
show_copy_button=True,
|
14 |
+
)
|
15 |
+
ddg_button = gr.Button(
|
16 |
+
variant='primary',
|
17 |
+
value='Search',
|
18 |
+
)
|
19 |
+
ddg_result = gr.Textbox(
|
20 |
+
lines=20,
|
21 |
+
label='Result',
|
22 |
+
interactive=True,
|
23 |
+
show_copy_button=True,
|
24 |
+
)
|
25 |
+
|
26 |
+
with gr.Tab('bs4'):
|
27 |
+
bs4_url = gr.Textbox(
|
28 |
+
lines=1,
|
29 |
+
label='URL',
|
30 |
+
interactive=True,
|
31 |
+
show_copy_button=True,
|
32 |
+
)
|
33 |
+
bs4_button = gr.Button(
|
34 |
+
variant='primary',
|
35 |
+
value='Scraping',
|
36 |
+
)
|
37 |
+
bs4_result = gr.Textbox(
|
38 |
+
lines=20,
|
39 |
+
label='Result',
|
40 |
+
interactive=True,
|
41 |
+
show_copy_button=True,
|
42 |
+
)
|
43 |
+
|
44 |
+
with gr.Tab('upload'):
|
45 |
+
gr.Markdown('name単位でsearchできます。行ごとにchunkになります。')
|
46 |
+
upload_name = gr.Textbox(
|
47 |
+
lines=1,
|
48 |
+
label='Name',
|
49 |
+
interactive=True,
|
50 |
+
show_copy_button=True,
|
51 |
+
)
|
52 |
+
upload_filename = gr.Textbox(
|
53 |
+
lines=1,
|
54 |
+
label='FileName',
|
55 |
+
interactive=True,
|
56 |
+
show_copy_button=True,
|
57 |
+
)
|
58 |
+
upload_content = gr.Textbox(
|
59 |
+
lines=20,
|
60 |
+
label='Content',
|
61 |
+
interactive=True,
|
62 |
+
show_copy_button=True,
|
63 |
+
)
|
64 |
+
upload_button = gr.Button(
|
65 |
+
variant='primary',
|
66 |
+
value='Upload',
|
67 |
+
)
|
68 |
+
|
69 |
+
with gr.Tab('delete'):
|
70 |
+
delete_name = gr.Textbox(
|
71 |
+
lines=1,
|
72 |
+
label='Name',
|
73 |
+
interactive=True,
|
74 |
+
show_copy_button=True,
|
75 |
+
)
|
76 |
+
delete_filename = gr.Textbox(
|
77 |
+
lines=1,
|
78 |
+
label='FileName',
|
79 |
+
interactive=True,
|
80 |
+
show_copy_button=True,
|
81 |
+
)
|
82 |
+
delete_button = gr.Button(
|
83 |
+
variant='primary',
|
84 |
+
value='Delete',
|
85 |
+
)
|
86 |
+
|
87 |
+
with gr.Tab('embedding'):
|
88 |
+
gr.Markdown('データベースを更新します。')
|
89 |
+
embedding_button = gr.Button(
|
90 |
+
variant='primary',
|
91 |
+
value='Embedding',
|
92 |
+
)
|
93 |
+
gr.Markdown('メモリのデータベースを再読み込みします。')
|
94 |
+
reload_button = gr.Button(
|
95 |
+
variant='primary',
|
96 |
+
value='Reload',
|
97 |
+
)
|
98 |
|
99 |
with gr.Tab('search'):
|
100 |
+
search_name = gr.Textbox(
|
101 |
+
lines=1,
|
102 |
+
label='Name',
|
103 |
+
interactive=True,
|
104 |
+
show_copy_button=True,
|
105 |
+
)
|
106 |
+
search_query = gr.Textbox(
|
107 |
+
lines=1,
|
108 |
+
label='Query',
|
109 |
+
interactive=True,
|
110 |
+
show_copy_button=True,
|
111 |
+
)
|
112 |
+
search_button = gr.Button(
|
113 |
+
variant='primary',
|
114 |
+
value='Search',
|
115 |
+
)
|
116 |
+
search_result = gr.Textbox(
|
117 |
+
label='Result',
|
118 |
+
lines=20,
|
119 |
+
interactive=True,
|
120 |
+
show_copy_button=True,
|
121 |
+
)
|
122 |
+
|
123 |
+
ddg_button.click(
|
124 |
+
fn=fn.ddg,
|
125 |
+
inputs=[ddg_query],
|
126 |
+
outputs=[ddg_result],
|
127 |
+
)
|
128 |
+
|
129 |
+
bs4_button.click(
|
130 |
+
fn=fn.bs4,
|
131 |
+
inputs=[bs4_url],
|
132 |
+
outputs=[bs4_result],
|
133 |
+
)
|
134 |
+
|
135 |
+
upload_button.click(
|
136 |
+
fn=fn.upload,
|
137 |
+
inputs=[upload_name, upload_filename, upload_content],
|
138 |
+
outputs=[info],
|
139 |
+
)
|
140 |
+
|
141 |
+
delete_button.click(
|
142 |
+
fn=fn.delete,
|
143 |
+
inputs=[delete_name, delete_filename],
|
144 |
+
outputs=[info],
|
145 |
+
)
|
146 |
+
|
147 |
+
embedding_button.click(
|
148 |
+
fn=fn.embedding,
|
149 |
+
inputs=[],
|
150 |
+
outputs=[info],
|
151 |
+
)
|
152 |
+
|
153 |
+
reload_button.click(
|
154 |
+
fn=fn.load_vectors,
|
155 |
+
inputs=[],
|
156 |
+
outputs=[info],
|
157 |
+
)
|
158 |
|
159 |
search_button.click(
|
160 |
fn=fn.search,
|
161 |
+
inputs=[search_name, search_query],
|
162 |
+
outputs=[search_result],
|
163 |
)
|
164 |
|
165 |
if __name__ == '__main__':
|