Y Phung Nguyen commited on
Commit
9099c51
·
1 Parent(s): dd13e35

Fix syntax

Browse files
Files changed (1) hide show
  1. pipeline.py +50 -49
pipeline.py CHANGED
@@ -56,55 +56,56 @@ def run_gemini_in_thread(fn, *args, **kwargs):
56
 
57
  def _supervisor_logics(fn_name: str, args: tuple):
58
  """Get appropriate fallback value based on function name"""
59
- if "breakdown" in fn_name:
60
- return {
61
- "sub_topics": [
62
- {"id": 1, "topic": "Answer", "instruction": args[0] if args else "Address the question", "expected_tokens": 400, "priority": "high", "approach": "direct answer"}
63
- ],
64
- "strategy": "Direct answer (fallback)",
65
- "exploration_note": "Gemini supervisor error"
66
- }
67
- elif "search_strategies" in fn_name:
68
- return {
69
- "search_strategies": [
70
- {"id": 1, "strategy": args[0] if args else "", "target_sources": 2, "focus": "main query"}
71
- ],
72
- "max_strategies": 1
73
- }
74
- elif "rag_brainstorm" in fn_name:
75
- return {
76
- "contexts": [
77
- {"id": 1, "context": args[1][:500] if len(args) > 1 else "", "focus": "retrieved information", "relevance": "high"}
78
- ],
79
- "max_contexts": 1
80
- }
81
- elif "synthesize" in fn_name:
82
- # Return concatenated MedSwin answers as fallback
83
- return "\n\n".join(args[1] if len(args) > 1 and args[1] else [])
84
- elif "challenge" in fn_name:
85
- return {"is_optimal": True, "completeness_score": 7, "accuracy_score": 7, "clarity_score": 7, "missing_aspects": [], "inaccuracies": [], "improvement_suggestions": [], "needs_more_context": False, "enhancement_instructions": ""}
86
- elif "enhance_answer" in fn_name:
87
- return args[1] if len(args) > 1 else ""
88
- elif "check_clarity" in fn_name:
89
- return {"is_unclear": False, "needs_search": False, "search_queries": []}
90
- elif "clinical_intake_triage" in fn_name:
91
- return {
92
- "needs_additional_info": False,
93
- "decision_reason": "Error fallback",
94
- "max_rounds": args[2] if len(args) > 2 else 5,
95
- "questions": [],
96
- "initial_hypotheses": []
97
- }
98
- elif "summarize_clinical_insights" in fn_name:
99
- return {
100
- "patient_profile": "",
101
- "refined_problem_statement": args[0] if args else "",
102
- "key_findings": [],
103
- "handoff_note": "Proceed with regular workflow."
104
- }
105
- else:
106
- logger.warning(f"[GEMINI SUPERVISOR] Unknown function {fn_name}, returning None")
107
- return None
 
108
  except Exception as e:
109
  logger.error(f"[GEMINI SUPERVISOR] Error running {fn.__name__} in thread: {e}")
110
  # Return appropriate fallback
 
56
 
57
  def _supervisor_logics(fn_name: str, args: tuple):
58
  """Get appropriate fallback value based on function name"""
59
+ try:
60
+ if "breakdown" in fn_name:
61
+ return {
62
+ "sub_topics": [
63
+ {"id": 1, "topic": "Answer", "instruction": args[0] if args else "Address the question", "expected_tokens": 400, "priority": "high", "approach": "direct answer"}
64
+ ],
65
+ "strategy": "Direct answer (fallback)",
66
+ "exploration_note": "Gemini supervisor error"
67
+ }
68
+ elif "search_strategies" in fn_name:
69
+ return {
70
+ "search_strategies": [
71
+ {"id": 1, "strategy": args[0] if args else "", "target_sources": 2, "focus": "main query"}
72
+ ],
73
+ "max_strategies": 1
74
+ }
75
+ elif "rag_brainstorm" in fn_name:
76
+ return {
77
+ "contexts": [
78
+ {"id": 1, "context": args[1][:500] if len(args) > 1 else "", "focus": "retrieved information", "relevance": "high"}
79
+ ],
80
+ "max_contexts": 1
81
+ }
82
+ elif "synthesize" in fn_name:
83
+ # Return concatenated MedSwin answers as fallback
84
+ return "\n\n".join(args[1] if len(args) > 1 and args[1] else [])
85
+ elif "challenge" in fn_name:
86
+ return {"is_optimal": True, "completeness_score": 7, "accuracy_score": 7, "clarity_score": 7, "missing_aspects": [], "inaccuracies": [], "improvement_suggestions": [], "needs_more_context": False, "enhancement_instructions": ""}
87
+ elif "enhance_answer" in fn_name:
88
+ return args[1] if len(args) > 1 else ""
89
+ elif "check_clarity" in fn_name:
90
+ return {"is_unclear": False, "needs_search": False, "search_queries": []}
91
+ elif "clinical_intake_triage" in fn_name:
92
+ return {
93
+ "needs_additional_info": False,
94
+ "decision_reason": "Error fallback",
95
+ "max_rounds": args[2] if len(args) > 2 else 5,
96
+ "questions": [],
97
+ "initial_hypotheses": []
98
+ }
99
+ elif "summarize_clinical_insights" in fn_name:
100
+ return {
101
+ "patient_profile": "",
102
+ "refined_problem_statement": args[0] if args else "",
103
+ "key_findings": [],
104
+ "handoff_note": "Proceed with regular workflow."
105
+ }
106
+ else:
107
+ logger.warning(f"[GEMINI SUPERVISOR] Unknown function {fn_name}, returning None")
108
+ return None
109
  except Exception as e:
110
  logger.error(f"[GEMINI SUPERVISOR] Error running {fn.__name__} in thread: {e}")
111
  # Return appropriate fallback