File size: 851 Bytes
7a8cb87
9b0ab3a
4d7bc75
9b0ab3a
 
e96c4ee
9b0ab3a
 
 
 
 
e96c4ee
9b0ab3a
 
 
 
4d7bc75
9b0ab3a
 
 
f621a6c
9b0ab3a
 
 
e96c4ee
9b0ab3a
 
7a8cb87
9b0ab3a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from vectordb import Memory

# Initialize Memory
memory = Memory()

# Save some example data
memory.save(
    ["apples are green", "oranges are orange"],  # save your text content
    [{"url": "https://apples.com"}, {"url": "https://oranges.com"}],  # associate metadata
)

# Define a function for querying
def search_query(query):
    results = memory.search(query, top_n=1)  # Search for top result
    return results

# Create Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("### VectorDB Search")
    
    with gr.Row():
        input_query = gr.Textbox(label="Enter your query")
        output_result = gr.Textbox(label="Search Results", interactive=False)

    search_button = gr.Button("Search")
    search_button.click(search_query, inputs=input_query, outputs=output_result)

# Run the Gradio app
demo.launch()