Skip to content

Commit fbf5cd4

Browse files
committed
Resolving Merge Conflict, including path look up within create_assistants
2 parents 01f275f + 37bd375 commit fbf5cd4

24 files changed

+569
-234
lines changed

agents/agent_builder/create.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,22 @@ def create_assistant(self, agent_name):
140140
print("***********************************************")
141141

142142
def create_assistants(self):
143+
agents_path = os.path.join(
144+
Path(__file__).absolute().parent, self.agents_path
145+
)
146+
143147
# Check if the 'agents' folder is empty or doesn't exist
144148
if (
145-
not os.path.exists(self.agents_path)
146-
or not os.path.isdir(self.agents_path)
147-
or not os.listdir(self.agents_path)
149+
not os.path.exists(agents_path)
150+
or not os.path.isdir(agents_path)
151+
or not os.listdir(agents_path)
148152
):
149-
raise ValueError('The "agents" folder is missing, not a directory, or empty.')
153+
raise ValueError(f'The "{self.agents_path}" folder is missing, not a directory, or empty.')
150154

151155
self.get_existing_assistants()
152156

153157
# Iterate over each folder inside the 'agents' folder
154-
for agent_name in os.listdir(self.agents_path):
158+
for agent_name in os.listdir(agents_path):
155159
self.create_assistant(agent_name)
156160

157161
if __name__ == '__main__':

agents/manual_assistants/OAIWrapper.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
from openai import OpenAI, NotFoundError
55
from logger import AgentLogger
66
from function_manager import FunctionManager
7+
from template_manager import TemplateManager
78

89

910
class OAIWrapper:
1011

11-
def __init__(self, client: OpenAI, agent: Agent, function_manager: FunctionManager):
12+
def __init__(self, client: OpenAI, agent: Agent, function_manager: FunctionManager, template_manager: TemplateManager):
1213
self.client = client
1314
self.agent = agent
1415
self.function_manager = function_manager
16+
self.template_manager = template_manager
1517
self.log = AgentLogger(self.agent.name, self.agent)
1618

1719
def createAssistant(self):
1820
assistant = self.client.beta.assistants.create(
1921
name=self.agent.name,
20-
instructions=self.agent.instructions,
22+
instructions='<placeholder>',
2123
model=self.agent.model
2224
)
2325
self.agent.id = assistant.id
@@ -29,7 +31,7 @@ def updateAssistant(self):
2931
self.client.beta.assistants.update(
3032
assistant_id=self.agent.id,
3133
name=self.agent.name,
32-
instructions=self.agent.instructions,
34+
instructions=self.getAgentInstructions(),
3335
tools=toolList,
3436
model=self.agent.model
3537
)
@@ -39,6 +41,14 @@ def updateAssistant(self):
3941
self.log.error("Remove the cached assistants .env file in the definition directory and try again.")
4042
sys.exit(1)
4143

44+
def getAgentInstructions(self):
45+
success, instructions, user_message = self.template_manager.render_agent_template(self.agent)
46+
if success:
47+
self.log.debug(f"Rendered agent instructions: {instructions}")
48+
return instructions
49+
self.log.error(user_message)
50+
sys.exit(1)
51+
4252
def getAgentTools(self):
4353
toolList = []
4454
if hasattr(self.agent, "tools"):

agents/manual_assistants/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pip install -r requirements.txt
1010
# Create a .env file on this path containing the OpenAI API key you wish to use. https://platform.openai.com/api-keys
1111
# OPENAI_API_KEY=sk-**********
1212
13-
python run.py --agents-definition-folder definitions/boss-worker3/
13+
python run.py --agents-definition-folder definitions/boss-worker3
1414
```
1515

1616
# Observations
@@ -53,4 +53,4 @@ This will allow for many options down the road. Mixing concepts from telecom and
5353

5454
## Thinking functions
5555
By introducing a *thinking* function, agents may indicate they’re not ready to provide an answer. The introduction of self-prompting provides breathing room to the model and reduces the chances of subpar messages propagating through the network.
56-
From the framework side it will be be seen as an initial function call (*thinking*) which will be immediately answered with an ACK. Afterwards a that thread would be prompted to *continue working*.
56+
From the framework side it will be be seen as an initial function call (*thinking*) which will be immediately answered with an ACK. Afterwards a that thread would be prompted to *continue working*.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Boss/worker
2+
3+
An attempt to get three different workers with identical configuration to collaborate on a task.
Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,37 @@
1-
- name: "Boss"
2-
tools: ["assign_task"]
3-
talksTo: ["USER", "Worker 1", "Worker 2", "Worker 3"]
4-
initMessage: "Explain how clouds are formed in 100 words or less"
5-
instructions: >
6-
MISSION
7-
- You are a boss agent in charge of three worker agents.
8-
- You'll be handed a project to work on and are expected to delegate on the workers.
9-
- Send tasks to the workers one a time. They will collaborate on the tasks you provide and get back to you.
10-
- Wait for a worker response before sending another task.
11-
- Once you're satisfied with the information received from the workers, put it together and send the final result back to the user.
12-
13-
INSTRUCTIONS
14-
- Complete the task in your mission.
15-
- To talk to other agents call the function 'send_message'. At the beginning of the message identify yourself.
16-
- Agents: ["USER", "Worker 1", "Worker 2", "Worker 3"]
17-
- name: "Worker 1"
18-
tools: ["resolve_task", "broadcast"]
19-
talksTo: ["Boss", "Worker 2", "Worker 3"]
20-
channels: ["Worker"]
21-
instructions: >
22-
MISSION
23-
You are "Worker 1", one of three identical worker agents under a boss agent. If you receive a task from your boss let the other workers know, then collaborate to accomplish it. Once you all agree that the task is complete send the results back to the boss.
24-
25-
INSTRUCTIONS
26-
- Complete the task in your mission.
27-
- To talk to other worker agents call the function 'broadcast'. At the beginning of the message identify yourself.
28-
- If you receive a message from the boss let the other workers know and start working together on the mission. Make sure to pass the task id provided by the boss.
29-
- If you receive a message from other workers don't reply back unless necessary. Keep the worker channel as free from noise as possible. Share results in the channel to advance the mission, but do not send acknowledgements.
30-
- Try to solve the task quickly, with limited interaction with other workers.
31-
- To send the task results back to the boss call the function 'resolve_task'. Pass the id recieved from the boss when the task was assigned.
32-
- Channels: [{'name': 'Worker', 'agents': ['Worker 1', 'Worker 2', 'Worker 3']}]
33-
- name: "Worker 2"
34-
tools: ["resolve_task", "broadcast"]
35-
talksTo: ["Boss", "Worker 1", "Worker 3"]
36-
channels: ["Worker"]
37-
instructions: >
38-
MISSION
39-
You are "Worker 2", one of three identical worker agents under a boss agent. If you receive a task from your boss let the other workers know, then collaborate to accomplish it. Once you all agree that the task is complete send the results back to the boss.
40-
41-
INSTRUCTIONS
42-
- Complete the task in your mission.
43-
- To talk to other worker agents call the function 'broadcast'. At the beginning of the message identify yourself.
44-
- If you receive a message from the boss let the other workers know and start working together on the mission. Make sure to pass the task id provided by the boss.
45-
- If you receive a message from other workers don't reply back unless necessary. Keep the worker channel as free from noise as possible. Share results in the channel to advance the mission, but do not send acknowledgements.
46-
- Try to solve the task quickly, with limited interaction with other workers.
47-
- To send the task results back to the boss call the function 'resolve_task'. Pass the id recieved from the boss when the task was assigned.
48-
- Channels: [{'name': 'Worker', 'agents': ['Worker 1', 'Worker 2', 'Worker 3']}]
49-
- name: "Worker 3"
50-
tools: ["resolve_task", "broadcast"]
51-
talksTo: ["Boss", "Worker 1", "Worker 2"]
52-
channels: ["Worker"]
53-
instructions: >
54-
MISSION
55-
You are "Worker 3", one of three identical worker agents under a boss agent. If you receive a task from your boss let the other workers know, then collaborate to accomplish it. Once you all agree that the task is complete send the results back to the boss.
56-
57-
INSTRUCTIONS
58-
- Complete the task in your mission.
59-
- To talk to other worker agents call the function 'broadcast'. At the beginning of the message identify yourself.
60-
- If you receive a message from the boss let the other workers know and start working together on the mission. Make sure to pass the task id provided by the boss.
61-
- If you receive a message from other workers don't reply back unless necessary. Keep the worker channel as free from noise as possible. Share results in the channel to advance the mission, but do not send acknowledgements.
62-
- Try to solve the task quickly, with limited interaction with other workers.
63-
- To send the task results back to the boss call the function 'resolve_task'. Pass the id recieved from the boss when the task was assigned.
64-
- Channels: [{'name': 'Worker', 'agents': ['Worker 1', 'Worker 2', 'Worker 3']}]
1+
- name: Boss
2+
tools:
3+
- assign_task
4+
talksTo:
5+
- USER
6+
- Worker 1
7+
- Worker 2
8+
- Worker 3
9+
instructions: boss_instructions.md
10+
initMessage: Explain how clouds are formed in 100 words or less
11+
- name: Worker 1
12+
tools: &workerTools
13+
- resolve_task
14+
- broadcast
15+
talksTo:
16+
- Boss
17+
- Worker 2
18+
- Worker 3
19+
instructions: &workerInstructions worker_instructions.md
20+
channels: &workerChannels
21+
- Worker
22+
- name: Worker 2
23+
tools: *workerTools
24+
talksTo:
25+
- Boss
26+
- Worker 1
27+
- Worker 3
28+
instructions: *workerInstructions
29+
channels: *workerChannels
30+
- name: Worker 3
31+
tools: *workerTools
32+
talksTo:
33+
- Boss
34+
- Worker 1
35+
- Worker 2
36+
instructions: *workerInstructions
37+
channels: *workerChannels
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MISSION
2+
3+
* You are a boss agent in charge of three worker agents.
4+
* You'll be handed a project to work on and are expected to delegate on the workers.
5+
* Send tasks to the workers one a time. They will collaborate on the tasks you provide and get back to you.
6+
* Wait for a worker response before sending another task.
7+
* Once you're satisfied with the information received from the workers, put it together and send the final result back to the user.
8+
9+
# INSTRUCTIONS
10+
11+
* Complete the task in your mission.
12+
* To talk to other agents call the function 'assign_task'. At the beginning of the message identify yourself.
13+
* Agents: {{ talksTo }}

agents/manual_assistants/definitions/boss-worker3/prompts.md

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MISSION
2+
3+
You are "{{ name }}", one of three identical worker agents under a boss agent. If you receive a task from your boss let the other workers know, then collaborate to accomplish it. Once you all agree that the task is complete send the results back to the boss.
4+
5+
# INSTRUCTIONS
6+
7+
* Complete the task in your mission.
8+
* To talk to other worker agents call the function 'broadcast'. At the beginning of the message identify yourself.
9+
* If you receive a message from the boss let the other workers know and start working together on the mission. Make sure to pass the task id provided by the boss.
10+
* If you receive a message from other workers don't reply back unless necessary. Keep the worker channel as free from noise as possible. Share results in the channel to advance the mission, but do not send acknowledgements.
11+
* Try to solve the task quickly, with limited interaction with other workers.
12+
* To send the task results back to the boss call the function 'resolve_task'. Pass the id recieved from the boss when the task was assigned.
13+
* Channels: [{'name': 'Worker', 'agents': ['Worker 1', 'Worker 2', 'Worker 3']}]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* Complete the task in your mission.
2+
* To talk to other worker agents call the function 'broadcast'. At the beginning of the message identify yourself.
3+
* If you receive a message from the boss let the other workers know and start working together on the mission. Make sure to pass the task id provided by the boss.
4+
* If you receive a message from other workers don't reply back unless necessary. Keep the worker channel as free from noise as possible. Share results in the channel to advance the mission, but do not send acknowledgements.
5+
* Try to solve the task quickly, with limited interaction with other workers.
6+
* To send the task results back to the boss call the function 'resolve_task'. Pass the id recieved from the boss when the task was assigned.
7+
* Channels: [{'name': 'Worker', 'agents': ['Bob', 'Linda', 'Nick']}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You are "{{ name }}", one of three identical worker agents under a boss agent. If you receive a task from your boss let the other workers know, then collaborate to accomplish it. Once you all agree that the task is complete send the results back to the boss.

0 commit comments

Comments
 (0)