Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -453,33 +453,23 @@ class PearlyBot:
|
|
453 |
- Professional limits"""
|
454 |
}
|
455 |
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
)
|
474 |
-
|
475 |
-
texts = text_splitter.split_text("\n\n".join(documents))
|
476 |
-
self.vector_store = FAISS.from_texts(texts, self.embeddings)
|
477 |
-
logger.info("RAG system setup complete")
|
478 |
-
|
479 |
-
return knowledge_base
|
480 |
-
except Exception as e:
|
481 |
-
logger.error(f"Error setting up RAG: {str(e)}")
|
482 |
-
raise
|
483 |
|
484 |
def _validate_rag_setup(self):
|
485 |
"""Validate RAG system setup"""
|
|
|
453 |
- Professional limits"""
|
454 |
}
|
455 |
|
456 |
+
# Create knowledge base directory
|
457 |
+
os.makedirs("knowledge_base", exist_ok=True)
|
458 |
+
|
459 |
+
# Write files and process documents
|
460 |
+
documents = []
|
461 |
+
for filename, content in knowledge_base.items():
|
462 |
+
filepath = os.path.join("knowledge_base", filename)
|
463 |
+
with open(filepath, "w", encoding="utf-8") as f:
|
464 |
+
f.write(content)
|
465 |
+
documents.append(content)
|
466 |
+
logger.info(f"Written knowledge base file: {filename}")
|
467 |
+
|
468 |
+
return knowledge_base
|
469 |
+
|
470 |
+
except Exception as e:
|
471 |
+
logger.error(f"Error loading knowledge base: {str(e)}")
|
472 |
+
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
def _validate_rag_setup(self):
|
475 |
"""Validate RAG system setup"""
|