Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -342,19 +342,6 @@ embedding_function = SentenceTransformerEmbeddingFunction("all-MiniLM-L6-v2")
|
|
| 342 |
chroma_client = chromadb.Client()
|
| 343 |
collection = chroma_client.get_or_create_collection("icodeguru_knowledge", embedding_function=embedding_function)
|
| 344 |
|
| 345 |
-
# --- Upload + load files as vector DB ---
|
| 346 |
-
def load_uploaded_vectors(uploaded_files):
|
| 347 |
-
data = []
|
| 348 |
-
for file in uploaded_files:
|
| 349 |
-
if file.name.endswith(".txt"):
|
| 350 |
-
text = file.read().decode()
|
| 351 |
-
data.append({"id": file.name, "content": text})
|
| 352 |
-
elif file.name.endswith(".json"):
|
| 353 |
-
content = json.load(file)
|
| 354 |
-
for i, chunk in enumerate(content):
|
| 355 |
-
data.append({"id": f"{file.name}-{i}", "content": chunk})
|
| 356 |
-
return data
|
| 357 |
-
|
| 358 |
def search_vector_data(query, data):
|
| 359 |
if not data:
|
| 360 |
return None
|
|
|
|
| 342 |
chroma_client = chromadb.Client()
|
| 343 |
collection = chroma_client.get_or_create_collection("icodeguru_knowledge", embedding_function=embedding_function)
|
| 344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
def search_vector_data(query, data):
|
| 346 |
if not data:
|
| 347 |
return None
|