Spaces:
Running
Running
| import os | |
| import sys | |
| # Add current dir to path to allow absolute imports | |
| sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__)))) | |
| import asyncio | |
| from app.core.config import settings | |
| from app.services.rag.embedder import embedder | |
| from app.services.rag.vector_store import vector_store | |
| from app.services.rag.rag_engine import rag_engine | |
| async def main(): | |
| print("Initializing embedder...") | |
| embedder.initialize() | |
| print(f"Embedder mode: {embedder.is_ready}, dimension: {embedder.dimension}") | |
| vec = embedder.embed_text("مرحبا بك في منصة عون") | |
| if vec: | |
| print(f"Embedding successful: Length {len(vec)}, first elements: {vec[:3]}") | |
| else: | |
| print("Embedding failed!") | |
| print("\nConnecting to Qdrant (Make sure Docker is running!)...") | |
| # This might fail if Docker Qdrant is not up, but it shouldn't crash the app. | |
| success = vector_store.connect() | |
| print(f"Qdrant connection: {success}") | |
| if success: | |
| print(vector_store.get_collection_info()) | |
| print("\nInitializing RAG Engine...") | |
| rag_engine.initialize() | |
| print(f"TF-IDF Matrix Shape: {rag_engine.tfidf_matrix.shape if rag_engine.tfidf_matrix is not None else 'None'}") | |
| print("\nTesting Hybrid Search:") | |
| res = rag_engine.search("كيف يتم دعم الأسر؟") | |
| for r in res: | |
| print(f"- [Score: {r['score']:.4f}]: {r['title']}") | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |