Skip to content

Commit f3610b9

Browse files
committed
fix(rag): correct dict iteration
1 parent 7fd0cea commit f3610b9

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

rag_pkg/gen_rag/api/chat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
Author: Ankur Sinha <sanjay DOT ankur AT gmail DOT com>
99
"""
1010

11+
import traceback
12+
1113
from fastapi import APIRouter, HTTPException, Request
1214

1315
chat_router = APIRouter()
@@ -19,7 +21,7 @@ async def query(request: Request, query: str):
1921
try:
2022
result = await rag.run_graph_invoke(query)
2123
except Exception as e:
22-
print(e)
23-
result = HTTPException(status_code=500, detail=str(e))
24+
detail = f"{e}\n{traceback.format_exc()}"
25+
result = HTTPException(status_code=500, detail=detail)
2426

2527
return {"result": result}

rag_pkg/gen_rag/rag.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def _classify_question_domain(self, state: RAGState) -> dict:
168168

169169
domain_str = ""
170170

171-
for d, info in domain_info:
172-
desc = info.get("description", None)
173-
if not desc:
171+
for d, info in domain_info.items():
172+
desc = info.description
173+
if not desc or len(desc) == 0:
174174
desc = f"if the question is about {d}"
175175
else:
176176
desc = f"if the question is about {desc}"

0 commit comments

Comments
 (0)