Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,42 +7,6 @@ import pandas as pd
|
|
7 |
from langchain_core.messages import HumanMessage
|
8 |
from agent import build_graph
|
9 |
|
10 |
-
import os
|
11 |
-
from datasets import load_dataset
|
12 |
-
from langchain.schema import Document
|
13 |
-
from langchain.embeddings import HuggingFaceEmbeddings
|
14 |
-
from langchain.vectorstores import SupabaseVectorStore
|
15 |
-
from supabase import create_client
|
16 |
-
|
17 |
-
# 1. Load GAIA train split
|
18 |
-
dataset = load_dataset("gaia-benchmark/GAIA", split="train")
|
19 |
-
|
20 |
-
# 2. Build Documents: "Q: …\nA: …"
|
21 |
-
docs = []
|
22 |
-
for ex in dataset:
|
23 |
-
q, a = ex["question"], ex["answer"]
|
24 |
-
docs.append(Document(
|
25 |
-
page_content=f"Q: {q}\nA: {a}",
|
26 |
-
metadata={"task_id": ex.get("task_id"), "split": "train"}
|
27 |
-
))
|
28 |
-
|
29 |
-
# 3. Initialize embedding & Supabase client
|
30 |
-
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
31 |
-
supabase_url = os.environ["SUPABASE_URL"]
|
32 |
-
supabase_key = os.environ["SUPABASE_SERVICE_KEY"]
|
33 |
-
supabase = create_client(supabase_url, supabase_key)
|
34 |
-
|
35 |
-
# 4. Upload to Supabase
|
36 |
-
vectorstore = SupabaseVectorStore.from_documents(
|
37 |
-
docs,
|
38 |
-
embedding=embeddings,
|
39 |
-
client=supabase,
|
40 |
-
table_name="documents",
|
41 |
-
query_name="match_documents_langchain"
|
42 |
-
)
|
43 |
-
|
44 |
-
print(f"Seeded {len(docs)} GAIA examples into Supabase.")
|
45 |
-
|
46 |
|
47 |
# (Keep Constants as is)
|
48 |
# --- Constants ---
|
|
|
7 |
from langchain_core.messages import HumanMessage
|
8 |
from agent import build_graph
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
# (Keep Constants as is)
|
12 |
# --- Constants ---
|