fix
Browse files- src/model.py +19 -3
src/model.py
CHANGED
|
@@ -1512,7 +1512,15 @@ def orchestrator_chat(history, query, use_rag, is_follow_up=False):
|
|
| 1512 |
reasoning = parsed_response.get("reasoning", [])
|
| 1513 |
if reasoning:
|
| 1514 |
if isinstance(reasoning, list):
|
| 1515 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1516 |
else:
|
| 1517 |
explanation = reasoning
|
| 1518 |
|
|
@@ -1520,8 +1528,16 @@ def orchestrator_chat(history, query, use_rag, is_follow_up=False):
|
|
| 1520 |
questions = parsed_response.get("follow_up_questions", [])
|
| 1521 |
if questions:
|
| 1522 |
if isinstance(questions, list):
|
| 1523 |
-
# Format as a numbered list
|
| 1524 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1525 |
else:
|
| 1526 |
follow_up_questions = questions
|
| 1527 |
|
|
|
|
| 1512 |
reasoning = parsed_response.get("reasoning", [])
|
| 1513 |
if reasoning:
|
| 1514 |
if isinstance(reasoning, list):
|
| 1515 |
+
# Check if each reasoning point already starts with a bullet point
|
| 1516 |
+
formatted_reasons = []
|
| 1517 |
+
for r in reasoning:
|
| 1518 |
+
# If item already starts with bullet, don't add another
|
| 1519 |
+
if r.strip().startswith("-") or r.strip().startswith("•"):
|
| 1520 |
+
formatted_reasons.append(r)
|
| 1521 |
+
else:
|
| 1522 |
+
formatted_reasons.append(f"- {r}")
|
| 1523 |
+
explanation = "\n".join(formatted_reasons)
|
| 1524 |
else:
|
| 1525 |
explanation = reasoning
|
| 1526 |
|
|
|
|
| 1528 |
questions = parsed_response.get("follow_up_questions", [])
|
| 1529 |
if questions:
|
| 1530 |
if isinstance(questions, list):
|
| 1531 |
+
# Format as a numbered list but check if already numbered
|
| 1532 |
+
formatted_questions = []
|
| 1533 |
+
for i, q in enumerate(questions):
|
| 1534 |
+
if q:
|
| 1535 |
+
# Check if question already starts with a number
|
| 1536 |
+
if re.match(r'^\d+\.', q.strip()):
|
| 1537 |
+
formatted_questions.append(q)
|
| 1538 |
+
else:
|
| 1539 |
+
formatted_questions.append(f"{i+1}. {q}")
|
| 1540 |
+
follow_up_questions = "\n".join(formatted_questions)
|
| 1541 |
else:
|
| 1542 |
follow_up_questions = questions
|
| 1543 |
|