Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import duckdb
|
3 |
+
from langchain_community.embeddings import HuggingFaceEmbeddings
|
4 |
+
from langchain_community.vectorstores import DuckDB
|
5 |
+
|
6 |
+
conn = duckdb.connect('your_database.duckdb')
|
7 |
+
|
8 |
+
embedding_function = HuggingFaceEmbeddings()
|
9 |
+
vector_store = DuckDB(conn, embedding_function)
|
10 |
+
|
11 |
+
# Define a data structure for user data
|
12 |
+
class User:
|
13 |
+
def __init__(self, phone: str, features: str):
|
14 |
+
self.phone = phone
|
15 |
+
self.features = features
|
16 |
+
def create(self):
|
17 |
+
vector_store.add_texts([f'#features\n{self.features}\n\n#phone\n{self.phone}')
|
18 |
+
def search(self):
|
19 |
+
return vector_store.similarity_search(self.features, k=1)
|
20 |
+
|
21 |
+
def greet(name):
|
22 |
+
return "Hello " + name + "!!"
|
23 |
+
|
24 |
+
demo = gr.Interface(fn=greet, inputs=["textbox", "button"], outputs="text")
|
25 |
+
# demo.launch()
|
26 |
+
demo.launch(share=True, auth=("username", "password"))
|