Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -200,46 +200,7 @@ if __name__ == "__main__":
|
|
| 200 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 201 |
demo.launch(debug=True, share=False)
|
| 202 |
'''
|
| 203 |
-
import
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
import chromadb
|
| 209 |
-
chromadb.config.Settings.telemetry_enabled = False
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
if __name__=='__main__':
|
| 213 |
-
with open('metadata.jsonl', 'r') as jsonl_file:
|
| 214 |
-
json_list = list(jsonl_file)
|
| 215 |
-
|
| 216 |
-
json_QA = []
|
| 217 |
-
for json_str in json_list:
|
| 218 |
-
json_data = json.loads(json_str)
|
| 219 |
-
json_QA.append(json_data)
|
| 220 |
-
|
| 221 |
-
# Usa gli stessi embeddings
|
| 222 |
-
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
| 223 |
-
print(1)
|
| 224 |
-
|
| 225 |
-
# Inizializza Chroma
|
| 226 |
-
|
| 227 |
-
from langchain.schema import Document
|
| 228 |
-
from langchain_community.vectorstores import Chroma
|
| 229 |
-
|
| 230 |
-
# Prepara la lista di documenti
|
| 231 |
-
docs = []
|
| 232 |
-
print("orig:",len(json_QA))
|
| 233 |
-
for sample in json_QA:
|
| 234 |
-
print(len(docs))
|
| 235 |
-
content = f"Question : {sample['Question']}\n\nFinal answer : {sample['Final answer']}"
|
| 236 |
-
metadata = {"source": sample['task_id']}
|
| 237 |
-
doc = Document(page_content=content, metadata=metadata)
|
| 238 |
-
docs.append(doc)
|
| 239 |
-
|
| 240 |
-
# Inizializza il vector store Chroma
|
| 241 |
-
vector_store = Chroma.from_documents(
|
| 242 |
-
documents=docs,
|
| 243 |
-
embedding=embeddings,
|
| 244 |
-
persist_directory="./chroma_db"
|
| 245 |
-
)
|
|
|
|
| 200 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 201 |
demo.launch(debug=True, share=False)
|
| 202 |
'''
|
| 203 |
+
import os
|
| 204 |
+
|
| 205 |
+
# Crea la cartella vuota se non esiste
|
| 206 |
+
os.makedirs("chroma_db", exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|