Some checks failed
CI/CD Pipeline / Lint Code (push) Failing after 7m34s
CI/CD Pipeline / Run Tests (push) Has been skipped
CI/CD Pipeline / Security Scanning (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (api) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (chat) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (frontend) (push) Has been skipped
CI/CD Pipeline / Build and Push Docker Images (worker) (push) Has been skipped
CI/CD Pipeline / Deploy to Staging (push) Has been skipped
CI/CD Pipeline / Deploy to Production (push) Has been skipped
CI/CD Pipeline / Generate Documentation (push) Failing after 7m59s
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Test script for RAG system in chat service
|
||
"""
|
||
|
||
import asyncio
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
# Add src to path
|
||
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
||
|
||
from datacenter_docs.chat.agent import DocumentationAgent
|
||
from datacenter_docs.utils.llm_client import get_llm_client
|
||
|
||
|
||
async def test_rag_search():
|
||
"""Test RAG search and retrieval"""
|
||
print("🧪 Testing RAG system...\n")
|
||
|
||
# Initialize agent
|
||
print("1️⃣ Initializing DocumentationAgent...")
|
||
agent = DocumentationAgent(vector_store_path="./data/chroma_db")
|
||
print("✅ Agent initialized\n")
|
||
|
||
# Test queries
|
||
test_queries = [
|
||
"Come è configurato smarthome-services?",
|
||
"Quali VM sono in esecuzione?",
|
||
"Come faccio il backup dei container?",
|
||
"Configurazione di storage su Proxmox",
|
||
]
|
||
|
||
for i, query in enumerate(test_queries, 1):
|
||
print(f"\n{'='*60}")
|
||
print(f"Query {i}: {query}")
|
||
print('='*60)
|
||
|
||
# Search documentation
|
||
results = await agent.search_documentation(query, limit=3)
|
||
|
||
if results:
|
||
print(f"\n📚 Found {len(results)} results:\n")
|
||
for j, result in enumerate(results, 1):
|
||
print(f" {j}. Section: {result['section']}")
|
||
print(f" Relevance: {result['relevance_score']:.3f} ({result['relevance_score']*100:.1f}%)")
|
||
print(f" Source: {Path(result['source']).name}")
|
||
print(f" Content preview: {result['content'][:100]}...")
|
||
print()
|
||
else:
|
||
print("❌ No results found")
|
||
|
||
print("\n" + "="*60)
|
||
print("✅ RAG test completed successfully!")
|
||
print("="*60)
|
||
|
||
|
||
if __name__ == "__main__":
|
||
asyncio.run(test_rag_search())
|