Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -126,10 +126,22 @@ orchestrator = AssistantAgent(
|
|
126 |
function_map={}
|
127 |
)
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
group_chat = GroupChat(
|
130 |
agents=[food_recognizer, size_estimator, nutrition_fetcher, orchestrator],
|
131 |
messages=[],
|
132 |
-
max_round=
|
|
|
133 |
)
|
134 |
manager = GroupChatManager(groupchat=group_chat)
|
135 |
|
@@ -150,7 +162,6 @@ def orchestrate_workflow(image, nutritionix_key):
|
|
150 |
result = response[-1].get("content", "No output from agents.")
|
151 |
print(f"Total time: {time.time() - start:.2f}s")
|
152 |
return result
|
153 |
-
|
154 |
|
155 |
# Gradio Interface
|
156 |
interface = gr.Interface(
|
|
|
126 |
function_map={}
|
127 |
)
|
128 |
|
129 |
+
# Custom speaker selection function (no LLM needed)
|
130 |
+
def custom_select_speaker(last_speaker, selector, messages, agents):
|
131 |
+
"""Select the next speaker in a fixed order: FoodRecognizer → SizeEstimator → NutritionFetcher → Orchestrator."""
|
132 |
+
if last_speaker is None:
|
133 |
+
return "FoodRecognizer" # Start with FoodRecognizer
|
134 |
+
order = ["FoodRecognizer", "SizeEstimator", "NutritionFetcher", "Orchestrator"]
|
135 |
+
current_index = order.index(last_speaker)
|
136 |
+
next_index = (current_index + 1) % len(order)
|
137 |
+
return order[next_index]
|
138 |
+
|
139 |
+
# Group Chat for Agent Coordination (no LLM, custom speaker selection)
|
140 |
group_chat = GroupChat(
|
141 |
agents=[food_recognizer, size_estimator, nutrition_fetcher, orchestrator],
|
142 |
messages=[],
|
143 |
+
max_round=4,
|
144 |
+
select_speaker=custom_select_speaker # Use custom speaker selection instead of LLM
|
145 |
)
|
146 |
manager = GroupChatManager(groupchat=group_chat)
|
147 |
|
|
|
162 |
result = response[-1].get("content", "No output from agents.")
|
163 |
print(f"Total time: {time.time() - start:.2f}s")
|
164 |
return result
|
|
|
165 |
|
166 |
# Gradio Interface
|
167 |
interface = gr.Interface(
|