forked from agent0ai/agent-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponse.py
More file actions
19 lines (13 loc) · 856 Bytes
/
response.py
File metadata and controls
19 lines (13 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from python.helpers.tool import Tool, Response
class ResponseTool(Tool):
async def execute(self, **kwargs):
return Response(message=self.args["text"] if "text" in self.args else self.args["message"], break_loop=True)
async def before_execution(self, **kwargs):
# self.log = self.agent.context.log.log(type="response", heading=f"{self.agent.agent_name}: Responding", content=self.args.get("text", ""))
# don't log here anymore, we have the live_response extension now
pass
async def after_execution(self, response, **kwargs):
# do not add anything to the history or output
if self.loop_data and "log_item_response" in self.loop_data.params_temporary:
log = self.loop_data.params_temporary["log_item_response"]
log.update(finished=True) # mark the message as finished