Dhruv-Ty commited on
Commit
6786f88
·
verified ·
1 Parent(s): d87f9c0

revert and fix - formatting

Browse files
Files changed (1) hide show
  1. src/model.py +22 -3
src/model.py CHANGED
@@ -1552,7 +1552,16 @@ def orchestrator_chat(history, query, use_rag, is_follow_up=False):
1552
  reasoning = parsed_response.get("reasoning", [])
1553
  if reasoning:
1554
  if isinstance(reasoning, list):
1555
- explanation = "\n".join([f"- {r}" for r in reasoning])
 
 
 
 
 
 
 
 
 
1556
  else:
1557
  explanation = reasoning
1558
 
@@ -1560,8 +1569,18 @@ def orchestrator_chat(history, query, use_rag, is_follow_up=False):
1560
  questions = parsed_response.get("follow_up_questions", [])
1561
  if questions:
1562
  if isinstance(questions, list):
1563
- # Format as a numbered list starting with 1
1564
- follow_up_questions = "\n".join([f"{i+1}. {q}" for i, q in enumerate(questions) if q])
 
 
 
 
 
 
 
 
 
 
1565
  else:
1566
  follow_up_questions = questions
1567
 
 
1552
  reasoning = parsed_response.get("reasoning", [])
1553
  if reasoning:
1554
  if isinstance(reasoning, list):
1555
+ # Check if each reasoning point already starts with a bullet point
1556
+ formatted_reasons = []
1557
+ for r in reasoning:
1558
+ if r: # Ensure 'r' is not None or empty before stripping
1559
+ # If item already starts with bullet, don't add another
1560
+ if r.strip().startswith("-") or r.strip().startswith("•"):
1561
+ formatted_reasons.append(r)
1562
+ else:
1563
+ formatted_reasons.append(f"- {r}")
1564
+ explanation = "\n".join(formatted_reasons)
1565
  else:
1566
  explanation = reasoning
1567
 
 
1569
  questions = parsed_response.get("follow_up_questions", [])
1570
  if questions:
1571
  if isinstance(questions, list):
1572
+ # Format as a numbered list starting with 1, but check if already numbered
1573
+ formatted_questions = []
1574
+ for i, q in enumerate(questions):
1575
+ if q: # Ensure 'q' is not None or empty
1576
+ # Check if question already starts with a number
1577
+ if re.match(r'^\s*\d+\.\s*', q.strip()):
1578
+ formatted_questions.append(q)
1579
+ else:
1580
+ # Remove any leading bullet points before adding numbers
1581
+ q_cleaned = re.sub(r'^\s*[-•*]\s*', '', q.strip())
1582
+ formatted_questions.append(f"{i+1}. {q_cleaned}")
1583
+ follow_up_questions = "\n".join(formatted_questions)
1584
  else:
1585
  follow_up_questions = questions
1586