Spaces:
Runtime error
Runtime error
try requirements
Browse files- app.py +14 -0
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,6 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
def greet(name):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
1 |
import gradio as gr
|
2 |
+
import chromadb
|
3 |
+
import pandas as pd
|
4 |
|
5 |
def greet(name):
|
6 |
+
client = chromadb.Client()
|
7 |
+
collection = client.create_collection("bolivian-recipes")
|
8 |
+
df = pd.read_parquet("hf://datasets/asoria/bolivian-recipes@~parquet/default/other/0000.parquet")
|
9 |
+
text_column = "preparation"
|
10 |
+
ids = [str(i) for i in range(df.shape[0])]
|
11 |
+
documents = df[text_column].to_list()
|
12 |
+
metadatas = df.drop(text_column, axis=1).to_dict("records")
|
13 |
+
|
14 |
+
collection.add(ids=ids, documents=documents, metadatas=metadatas)
|
15 |
+
|
16 |
+
results = collection.query(query_texts=["sausage"], n_results=4)
|
17 |
+
print(results)
|
18 |
return "Hello " + name + "!!"
|
19 |
|
20 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
chromadb
|
2 |
+
pandas
|