File size: 852 Bytes
2069ee0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import duckdb
from langchain_community.embeddings import HuggingFaceEmbeddings
from langchain_community.vectorstores import DuckDB

conn = duckdb.connect('your_database.duckdb')

embedding_function = HuggingFaceEmbeddings()
vector_store = DuckDB(conn, embedding_function)

# Define a data structure for user data
class User:
    def __init__(self, phone: str, features: str):
        self.phone = phone
        self.features = features
    def create(self):
        vector_store.add_texts([f'#features\n{self.features}\n\n#phone\n{self.phone}')
    def search(self):
        return vector_store.similarity_search(self.features, k=1)

def greet(name):
    return "Hello " + name + "!!"

demo = gr.Interface(fn=greet, inputs=["textbox", "button"], outputs="text")
# demo.launch()
demo.launch(share=True, auth=("username", "password"))