Spaces:
Sleeping
Sleeping
| import fn | |
| import gradio as gr | |
| with gr.Blocks() as demo: | |
| gr.Markdown('# vector_search') | |
| info = gr.Markdown() | |
| with gr.Tab('ddg'): | |
| ddg_query = gr.Textbox( | |
| lines=1, | |
| label='Query', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| ddg_button = gr.Button( | |
| variant='primary', | |
| value='Search', | |
| ) | |
| ddg_result = gr.Textbox( | |
| lines=20, | |
| label='Result', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| with gr.Tab('bs4'): | |
| bs4_url = gr.Textbox( | |
| lines=1, | |
| label='URL', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| bs4_button = gr.Button( | |
| variant='primary', | |
| value='Scraping', | |
| ) | |
| bs4_result = gr.Textbox( | |
| lines=20, | |
| label='Result', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| with gr.Tab('md'): | |
| md_url = gr.Textbox( | |
| lines=1, | |
| label='URL', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| md_button = gr.Button( | |
| variant='primary', | |
| value='Scraping', | |
| ) | |
| md_result = gr.Textbox( | |
| lines=20, | |
| label='Result', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| with gr.Tab('upload'): | |
| gr.Markdown('name単位でsearchできます。行ごとにchunkになります。') | |
| upload_name = gr.Textbox( | |
| lines=1, | |
| label='Name', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| upload_filename = gr.Textbox( | |
| lines=1, | |
| label='FileName', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| upload_content = gr.Textbox( | |
| lines=20, | |
| label='Content', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| upload_button = gr.Button( | |
| variant='primary', | |
| value='Upload', | |
| ) | |
| with gr.Tab('delete'): | |
| delete_name = gr.Textbox( | |
| lines=1, | |
| label='Name', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| delete_filename = gr.Textbox( | |
| lines=1, | |
| label='FileName', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| delete_button = gr.Button( | |
| variant='primary', | |
| value='Delete', | |
| ) | |
| with gr.Tab('embedding'): | |
| gr.Markdown('データベースを更新します。') | |
| embedding_button = gr.Button( | |
| variant='primary', | |
| value='Embedding', | |
| ) | |
| gr.Markdown('メモリのデータベースを再読み込みします。') | |
| reload_button = gr.Button( | |
| variant='primary', | |
| value='Reload', | |
| ) | |
| with gr.Tab('search'): | |
| search_name = gr.Textbox( | |
| lines=1, | |
| label='Name', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| search_query = gr.Textbox( | |
| lines=1, | |
| label='Query', | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| search_button = gr.Button( | |
| variant='primary', | |
| value='Search', | |
| ) | |
| search_result = gr.Textbox( | |
| label='Result', | |
| lines=20, | |
| interactive=True, | |
| show_copy_button=True, | |
| ) | |
| ddg_button.click( | |
| fn=fn.ddg, | |
| inputs=[ddg_query], | |
| outputs=[ddg_result], | |
| ) | |
| bs4_button.click( | |
| fn=fn.bs4, | |
| inputs=[bs4_url], | |
| outputs=[bs4_result], | |
| ) | |
| md_button.click( | |
| fn=fn.md, | |
| inputs=[md_url], | |
| outputs=[md_result], | |
| ) | |
| upload_button.click( | |
| fn=fn.upload, | |
| inputs=[upload_name, upload_filename, upload_content], | |
| outputs=[info], | |
| ) | |
| delete_button.click( | |
| fn=fn.delete, | |
| inputs=[delete_name, delete_filename], | |
| outputs=[info], | |
| ) | |
| embedding_button.click( | |
| fn=fn.embedding, | |
| inputs=[], | |
| outputs=[info], | |
| ) | |
| reload_button.click( | |
| fn=fn.load_vectors, | |
| inputs=[], | |
| outputs=[info], | |
| ) | |
| search_button.click( | |
| fn=fn.search, | |
| inputs=[search_name, search_query], | |
| outputs=[search_result], | |
| ) | |
| if __name__ == '__main__': | |
| demo.launch() | |