Update app.py
Browse filesFixed a bug where the user input instead of the final (approved by the critic) code was sent to the documentation agent which caused it to produce documentation that did not align with the final result.
It should be better now!
app.py
CHANGED
@@ -49,18 +49,29 @@ async def async_stream_task(task_message, api_key, primary_system_message, criti
|
|
49 |
|
50 |
llm_config = create_llm_config(api_key)
|
51 |
team, model_client = create_team(llm_config, primary_system_message, critic_system_message)
|
|
|
52 |
documentation_triggered = False # Track if documentation agent was triggered
|
53 |
final_output = None # Store the final approved output
|
54 |
|
|
|
|
|
|
|
55 |
try:
|
56 |
async for message in team.run_stream(task=task_message):
|
57 |
if hasattr(message, "source") and hasattr(message, "content"):
|
|
|
|
|
|
|
|
|
|
|
58 |
# Handle critic's approval
|
59 |
if message.source == "critic" and "APPROVE" in message.content:
|
60 |
print("Critic approved the response. Handing off to Documentation Agent...")
|
61 |
documentation_triggered = True
|
62 |
-
|
|
|
63 |
break
|
|
|
64 |
yield message.source, message.content
|
65 |
|
66 |
# Trigger Documentation Agent if approved
|
@@ -124,7 +135,7 @@ iface = gr.Interface(
|
|
124 |
description="""Collaborative workflow between Primary, Critic, and Documentation agents.
|
125 |
1. The user can send a prompt to the primary agent.
|
126 |
2. The response will then be evaluated by the critic, which either sends feedback back to the primary agent or gives the APPROVAL sign.
|
127 |
-
3. If the APPROVAL sign is given, the documentation agent is asked to write a short documentation for the code (that has been approved by the critic and generated by the
|
128 |
4. (Note: There is a hard cap of 10 messages for the critic to approve the output of the primary agent. If it fails to do so the workflow is interrupted to prevent long loops)"""
|
129 |
)
|
130 |
|
|
|
49 |
|
50 |
llm_config = create_llm_config(api_key)
|
51 |
team, model_client = create_team(llm_config, primary_system_message, critic_system_message)
|
52 |
+
|
53 |
documentation_triggered = False # Track if documentation agent was triggered
|
54 |
final_output = None # Store the final approved output
|
55 |
|
56 |
+
# Variable to store the latest code snippet from the primary agent
|
57 |
+
latest_primary_code = ""
|
58 |
+
|
59 |
try:
|
60 |
async for message in team.run_stream(task=task_message):
|
61 |
if hasattr(message, "source") and hasattr(message, "content"):
|
62 |
+
|
63 |
+
# If it's from the primary agent, store the latest code snippet
|
64 |
+
if message.source == "primary":
|
65 |
+
latest_primary_code = message.content
|
66 |
+
|
67 |
# Handle critic's approval
|
68 |
if message.source == "critic" and "APPROVE" in message.content:
|
69 |
print("Critic approved the response. Handing off to Documentation Agent...")
|
70 |
documentation_triggered = True
|
71 |
+
# Capture the primary agent's final code
|
72 |
+
final_output = latest_primary_code
|
73 |
break
|
74 |
+
|
75 |
yield message.source, message.content
|
76 |
|
77 |
# Trigger Documentation Agent if approved
|
|
|
135 |
description="""Collaborative workflow between Primary, Critic, and Documentation agents.
|
136 |
1. The user can send a prompt to the primary agent.
|
137 |
2. The response will then be evaluated by the critic, which either sends feedback back to the primary agent or gives the APPROVAL sign.
|
138 |
+
3. If the APPROVAL sign is given, the documentation agent is asked to write a short documentation for the code (that has been approved by the critic and generated by the primary agent).
|
139 |
4. (Note: There is a hard cap of 10 messages for the critic to approve the output of the primary agent. If it fails to do so the workflow is interrupted to prevent long loops)"""
|
140 |
)
|
141 |
|