Spaces:
Running
on
Zero
Running
on
Zero
Y Phung Nguyen
commited on
Commit
·
9099c51
1
Parent(s):
dd13e35
Fix syntax
Browse files- 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 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
| 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
|