Skip to content

Commit

Permalink
Change name of agent in final response to assitent and text to 'Final…
Browse files Browse the repository at this point in the history
… Cut', drive status by failed agent responses
  • Loading branch information
ashish-spext committed Oct 28, 2024
1 parent 9d45b36 commit 450c5e2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions backend/director/core/reasoning.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(
self.stop_flag = False
self.output_message: OutputMessage = self.session.output_message
self.summary_content = None
self.failed_agents = []

def register_agents(self, agents: List[BaseAgent]):
"""Register an agents.
Expand Down Expand Up @@ -124,12 +125,12 @@ def get_current_run_context(self):

def remove_summary_content(self):
for i in range(len(self.output_message.content) - 1, -1, -1):
if self.output_message.content[i].agent_name == "reasoning_engine":
if self.output_message.content[i].agent_name == "assistant":
self.output_message.content.pop(i)
self.summary_content = None

def add_summary_content(self):
self.summary_content = TextContent(agent_name="reasoning_engine")
self.summary_content = TextContent(agent_name="assistant")
self.output_message.content.append(self.summary_content)
self.summary_content.status_message = "Consolidating outcomes..."
self.summary_content.status = MsgStatus.progress
Expand Down Expand Up @@ -207,6 +208,8 @@ def step(self):
tool_call["tool"]["name"],
**tool_call["tool"]["arguments"],
)
if agent_response.status == AgentStatus.ERROR:
self.failed_agents.append(tool_call["tool"]["name"])
self.session.reasoning_context.append(
ContextMessage(
content=agent_response.__str__(),
Expand Down Expand Up @@ -234,9 +237,7 @@ def step(self):
)
if self.iterations == self.max_iterations - 1:
# Direct response case
self.summary_content.status_message = (
"Here is the the response"
)
self.summary_content.status_message = "Here is the the response"
self.summary_content.text = llm_response.content
self.summary_content.status = MsgStatus.success
else:
Expand All @@ -255,10 +256,11 @@ def step(self):
]
)
self.summary_content.text = summary_response.content
self.summary_content.status = MsgStatus.success
self.summary_content.status_message = (
"Here is the summary of the run"
)
if self.failed_agents:
self.summary_content.status = MsgStatus.error
else:
self.summary_content.status = MsgStatus.success
self.summary_content.status_message = "Final Cut"
self.output_message.status = MsgStatus.success
self.output_message.publish()
print("-" * 40, "Stopping", "-" * 40)
Expand Down

0 comments on commit 450c5e2

Please sign in to comment.