fixed the RAg in test pipeline issue

This commit is contained in:
belviskhoremk
2026-04-26 21:43:19 +00:00
parent 78023ae9c5
commit 260a9c6353
9 changed files with 262 additions and 78 deletions

View File

@@ -1,3 +1,4 @@
import asyncio
import time
from collections import defaultdict
@@ -311,8 +312,7 @@ async def test_chat(
company_data = chatbot.get("companies", {}) or {}
chatbot_config = {**chatbot, "company_name": company_data.get("name", "")}
results = []
for question in body.questions:
async def _run_one(question: str) -> TestChatResult:
try:
result = await rag_engine.process_query(
query=question,
@@ -322,22 +322,24 @@ async def test_chat(
language="auto",
bypass_cache=True,
)
results.append(TestChatResult(
return TestChatResult(
question=question,
response=result["response"],
confidence_score=result.get("confidence_score", 0.0),
sources=result.get("sources", []),
model_used=result.get("model", ""),
))
)
except Exception as e:
results.append(TestChatResult(
return TestChatResult(
question=question,
response=f"Error: {e}",
confidence_score=0.0,
sources=[],
model_used="",
))
return results
)
results = await asyncio.gather(*[_run_one(q) for q in body.questions])
return list(results)
# ── OLD analytics endpoint REMOVED ───────────────────────────────────────────