frdel commited on
Commit
6e950a4
·
1 Parent(s): dadf583

Update call_subordinate.py

Browse files
Files changed (1) hide show
  1. python/tools/call_subordinate.py +12 -9
python/tools/call_subordinate.py CHANGED
@@ -1,6 +1,6 @@
1
  from agent import Agent, UserMessage
2
  from python.helpers.tool import Tool, Response
3
- import copy
4
 
5
 
6
  class Delegation(Tool):
@@ -11,22 +11,25 @@ class Delegation(Tool):
11
  self.agent.get_data(Agent.DATA_NAME_SUBORDINATE) is None
12
  or str(reset).lower().strip() == "true"
13
  ):
 
 
 
 
 
 
 
 
14
  # crate agent
15
- sub = Agent(self.agent.number + 1, copy.deepcopy(self.agent.config), self.agent.context)
16
  # register superior/subordinate
17
  sub.set_data(Agent.DATA_NAME_SUPERIOR, self.agent)
18
  self.agent.set_data(Agent.DATA_NAME_SUBORDINATE, sub)
19
- # set default prompt profile to new agents
20
- sub.config.profile = ""
21
 
22
  # add user message to subordinate agent
23
- subordinate: Agent = self.agent.get_data(Agent.DATA_NAME_SUBORDINATE)
24
  subordinate.hist_add_user_message(UserMessage(message=message, attachments=[]))
25
 
26
- # set subordinate prompt profile if provided, if not, keep original
27
- agent_profile = kwargs.get("profile")
28
- if agent_profile:
29
- subordinate.config.profile = agent_profile
30
 
31
  # run subordinate monologue
32
  result = await subordinate.monologue()
 
1
  from agent import Agent, UserMessage
2
  from python.helpers.tool import Tool, Response
3
+ from initialize import initialize_agent
4
 
5
 
6
  class Delegation(Tool):
 
11
  self.agent.get_data(Agent.DATA_NAME_SUBORDINATE) is None
12
  or str(reset).lower().strip() == "true"
13
  ):
14
+ # initialize default config
15
+ config = initialize_agent()
16
+
17
+ # set subordinate prompt profile if provided, if not, keep original
18
+ agent_profile = kwargs.get("profile")
19
+ if agent_profile:
20
+ config.profile = agent_profile
21
+
22
  # crate agent
23
+ sub = Agent(self.agent.number + 1, config, self.agent.context)
24
  # register superior/subordinate
25
  sub.set_data(Agent.DATA_NAME_SUPERIOR, self.agent)
26
  self.agent.set_data(Agent.DATA_NAME_SUBORDINATE, sub)
 
 
27
 
28
  # add user message to subordinate agent
29
+ subordinate: Agent = self.agent.get_data(Agent.DATA_NAME_SUBORDINATE) # type: ignore
30
  subordinate.hist_add_user_message(UserMessage(message=message, attachments=[]))
31
 
32
+
 
 
 
33
 
34
  # run subordinate monologue
35
  result = await subordinate.monologue()