mirror of
http://88.130.71.182:3000/BlitTech/contexta_be.git
synced 2026-06-13 08:30:07 +00:00
fixed the RAg in test pipeline issue
This commit is contained in:
@@ -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 ───────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user