Spaces:
Runtime error
Runtime error
Download tools/test_query.py from yuvis/Enterprise-RAG-System: direct link, hf CLI and curl.
- Browser
- Download file 956 Bytes
-
https://huggingface.co/spaces/yuvis/Enterprise-RAG-System/resolve/main/tools/test_query.py
- Command line
-
hf download hf://spaces/yuvis/Enterprise-RAG-System/tools/test_query.py
-
curl -L -o test_query.py https://huggingface.co/spaces/yuvis/Enterprise-RAG-System/resolve/main/tools/test_query.py
956 Bytes
| import os | |
| from src.pipeline.query_pipeline import QueryPipeline | |
| def test_manual_query(): | |
| print("Initializing Pipeline...") | |
| pipeline = QueryPipeline() | |
| query = 'what is emerging contaminants according to DOD?' | |
| print(f"\nProcessing Query: {query}") | |
| # Run pipeline | |
| result = pipeline.run(query, top_k_retrieval=5, top_k_rerank=3) | |
| print("\n--- Retrieved Context (Top 3) ---") | |
| for doc, score in result['context']: | |
| content = doc if isinstance(doc, str) else doc['content'] | |
| print(f"[Score: {score:.4f}] {content[:150]}...") | |
| print("\n--- Generated Answer ---") | |
| print(result['answer']) | |
| print("\n--- Scores ---") | |
| print(f"Retrieval Score: {result.get('retrieval_score', 'N/A')}") | |
| print(f"Hallucination Score: {result.get('hallucination_score', 'N/A')}") | |
| print(f"Groundedness: {result.get('groundedness', 'N/A')}") | |
| if __name__ == "__main__": | |
| test_manual_query() | |