Spaces:
Running
Running
| import sys, os | |
| from pathlib import Path | |
| sys.path.append(str(Path(__file__).parent.parent)) | |
| import src.core.win_fix | |
| from src.core.rag_pipeline import RAGPipeline | |
| def run_test(): | |
| print("==================================================") | |
| print("🧪 Testing DocBrain RAG Pipeline with Local LLM") | |
| print("==================================================") | |
| pipeline = RAGPipeline() | |
| session_id = "session_582b8d994da8" | |
| session_docs = ["20260319_VNM_Bao_cao_thuong_nien_2025_eae619d5f6.pdf"] | |
| test_questions = [ | |
| "Bạn có phải ai không", | |
| "Con bot này tên gì", | |
| "Bạn có thể làm được gì cho tôi", | |
| "Haha thú vị đấy", | |
| "Bạn có biết tên tôi là gì không", | |
| "Xin chào", | |
| "Tài liệu này là gì", | |
| "Doanh thu Vinamilk 2025 là bao nhiêu", | |
| "Tôi buồn quá", | |
| "Hãy động viên tôi đi", | |
| ] | |
| for q in test_questions: | |
| print(f"\n❓ Câu hỏi: {q}") | |
| res = pipeline.ask(query=q, session_id=session_id, session_docs=session_docs, top_k=3) | |
| print(f"⏱️ {res['execution_time_sec']}s | 🎯 {res.get('confidence', 0)*100}% | API Used: {res.get('used_api', False)}") | |
| print(f"💡 {res['answer']}") | |
| for src in res.get("sources", []): | |
| print(f" [{src['id']}] {src['source_file']} (Trang {src['page']}) - Score: {src['relevance_score']}") | |
| print("-" * 60) | |
| if __name__ == "__main__": | |
| run_test() | |