Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
f37fb64
Initial commit
daveshap Nov 7, 2023
2a364c1
Update README.md
daveshap Nov 7, 2023
8a71842
Add files via upload
daveshap Nov 7, 2023
b7abe98
ready to record
daveshap Nov 8, 2023
6dcc649
adding contributing
daveshap Nov 8, 2023
17bbb3f
Add successful Autonomous Swarm Agent Builder system prompt
guillermo-delrio Nov 9, 2023
122849d
Merge pull request #12 from guillermo-delrio/main
daveshap Nov 9, 2023
eade8dc
Add Python script to create agents
guillermo-delrio Nov 9, 2023
f3cdf67
morning updates
daveshap Nov 9, 2023
17236bf
Merge pull request #1 from guillermo-delrio/main
guillermo-delrio Nov 9, 2023
0e5a21d
updating contributing and readme
daveshap Nov 9, 2023
977c67e
updating agent builder readme
daveshap Nov 9, 2023
5932896
Restructure
guillermo-delrio Nov 9, 2023
c3b4ef1
Merge pull request #15 from guillermo-delrio/feature/automatic-creation
daveshap Nov 9, 2023
dfe74b7
Start working on a direct agent connector
guillermo-delrio Nov 9, 2023
3ad16d4
Fix queue system
guillermo-delrio Nov 9, 2023
cefeab4
Fix typo in agent_definition.md
gokhanmeteerturk Nov 10, 2023
02eaeaa
tool-making-assistants
OWigginsHay Nov 10, 2023
2fd6471
Merge pull request #49 from OWigginsHay/tool_making
daveshap Nov 10, 2023
98c4009
Merge pull request #48 from gokhanmeteerturk/main
daveshap Nov 10, 2023
c604925
Update README.md
daveshap Nov 10, 2023
22de55f
add tool demo
joseph-crowley Nov 10, 2023
a8708f3
Merge remote-tracking branch 'upstream/main'
joseph-crowley Nov 10, 2023
0870398
Merge pull request #52 from joseph-crowley/main
daveshap Nov 10, 2023
6d44c20
Slight modifications and img folder creation
OWigginsHay Nov 10, 2023
bbed913
Slight modifications and img folder creation
OWigginsHay Nov 10, 2023
633af7f
Fix typo in Theoretical Foundation section
dejecj Nov 10, 2023
cfc7316
Adding logic to prevent the creation of duplicate agents, and to prev…
FireMMDC Nov 11, 2023
36727be
Adding logic to prevent the creation of duplicate agents, and to prev…
FireMMDC Nov 11, 2023
77f39c3
Merge remote-tracking branch 'upstream/main' into tool_making
OWigginsHay Nov 11, 2023
f5e7f95
Merge remote-tracking branch 'upstream/main' into tool_making
OWigginsHay Nov 11, 2023
22fbf8e
Update README.md
eltociear Nov 11, 2023
8cfee2e
Merge pull request #63 from eltociear/patch-1
daveshap Nov 11, 2023
4ea803e
Merge pull request #59 from dejecj/patch-1
daveshap Nov 11, 2023
f0130bf
Merge pull request #65 from guillermo-delrio/feature/connect-agents
daveshap Nov 11, 2023
c2255e0
Implement funcion calling
guillermo-delrio Nov 11, 2023
d285d34
Implement funcion calling
guillermo-delrio Nov 11, 2023
28efa48
Debug
guillermo-delrio Nov 11, 2023
3055cd8
Debug
guillermo-delrio Nov 11, 2023
0d65fff
Improve prompts
guillermo-delrio Nov 11, 2023
20ec5b4
Improve prompts
guillermo-delrio Nov 11, 2023
86f41b5
Update README.md
guillermo-delrio Nov 11, 2023
5ae9268
Update README.md
guillermo-delrio Nov 11, 2023
3e7b6f2
Updated existing_assitstants to existing_assistants
FireMMDC Nov 11, 2023
cadb7e6
Updated existing_assitstants to existing_assistants
FireMMDC Nov 11, 2023
25ddb6a
Build basic boss-worker topology. Still very buggy
guillermo-delrio Nov 11, 2023
6e9a4d9
Build basic boss-worker topology. Still very buggy
guillermo-delrio Nov 11, 2023
0be7d03
Adding a settings.json file to maintain the additional parameters ava…
FireMMDC Nov 12, 2023
eac0bf7
Adding a settings.json file to maintain the additional parameters ava…
FireMMDC Nov 12, 2023
62d744d
Refined Tool Function Chain
OWigginsHay Nov 12, 2023
032d8f4
Refined Tool Function Chain
OWigginsHay Nov 12, 2023
29aaba3
Merge pull request #88 from OWigginsHay/tool_making
daveshap Nov 12, 2023
3d8fdd2
Merge pull request #88 from OWigginsHay/tool_making
daveshap Nov 12, 2023
45af8cb
Update README.md
daveshap Nov 12, 2023
4dc3dea
Update README.md
daveshap Nov 12, 2023
4d5ee8e
Merge pull request #60 from FireMMDC/main
daveshap Nov 12, 2023
0e37044
Merge pull request #60 from FireMMDC/main
daveshap Nov 12, 2023
a9281c0
Update tool-maker README.md
kruemelo Nov 12, 2023
a8e4711
Update tool-maker README.md
kruemelo Nov 12, 2023
c548c27
Merge pull request #94 from kruemelo/toolmaker-readme-typo
daveshap Nov 12, 2023
2017c39
Merge pull request #94 from kruemelo/toolmaker-readme-typo
daveshap Nov 12, 2023
8a765c8
Restructure repo
romangoempire Nov 12, 2023
86fa9d9
Restructure repo
romangoempire Nov 12, 2023
3cf2550
remove tool-demo.py
romangoempire Nov 12, 2023
7b1a68f
remove tool-demo.py
romangoempire Nov 12, 2023
3d6bfc0
Create code_of_conduct.md
daveshap Nov 12, 2023
52faefa
Create code_of_conduct.md
daveshap Nov 12, 2023
5160fd3
Hotfix to make functions folder if it doesn't already exist
OWigginsHay Nov 12, 2023
86dd2cf
Hotfix to make functions folder if it doesn't already exist
OWigginsHay Nov 12, 2023
c587700
Removed PYC
OWigginsHay Nov 12, 2023
d9e3fad
Removed PYC
OWigginsHay Nov 12, 2023
bdbab06
Merge pull request #99 from OWigginsHay/main
OWigginsHay Nov 12, 2023
3f0f114
Merge pull request #99 from OWigginsHay/main
OWigginsHay Nov 12, 2023
8eacafb
synced chat_manager.py changes
romangoempire Nov 12, 2023
c4e31bf
synced chat_manager.py changes
romangoempire Nov 12, 2023
a6be04c
further synced tool-maker
romangoempire Nov 12, 2023
c63a166
further synced tool-maker
romangoempire Nov 12, 2023
34b75a5
Merge branch 'pr/98'
OWigginsHay Nov 12, 2023
099add1
Merge branch 'pr/98'
OWigginsHay Nov 12, 2023
d316de7
reset chat_manager
romangoempire Nov 12, 2023
41012b2
reset chat_manager
romangoempire Nov 12, 2023
27b3955
Merge branch 'restructure-repo' of https://github.com/RomanGoEmpire/O…
romangoempire Nov 12, 2023
af1a80a
Merge branch 'restructure-repo' of https://github.com/RomanGoEmpire/O…
romangoempire Nov 12, 2023
6ec6517
Merge pull request #98 from RomanGoEmpire/restructure-repo
OWigginsHay Nov 12, 2023
9bb8bd2
Merge pull request #98 from RomanGoEmpire/restructure-repo
OWigginsHay Nov 12, 2023
86cb394
Dynamic paths with new file structure
OWigginsHay Nov 12, 2023
5a0f6c9
Dynamic paths with new file structure
OWigginsHay Nov 12, 2023
cdb20d9
Merge branch 'main' into bugfix-static_paths
OWigginsHay Nov 12, 2023
e26f36c
Merge branch 'main' into bugfix-static_paths
OWigginsHay Nov 12, 2023
bfbb308
Merge pull request #102 from OWigginsHay/main
OWigginsHay Nov 12, 2023
053c068
Merge pull request #102 from OWigginsHay/main
OWigginsHay Nov 12, 2023
8d2d38c
centralise client setup and access of api key
alex-straw Nov 11, 2023
42939a4
centralise client setup and access of api key
alex-straw Nov 11, 2023
34266b7
PR Feedback: Use Pydantic to create a central place to load env vars …
alex-straw Nov 11, 2023
71b5d5f
PR Feedback: Use Pydantic to create a central place to load env vars …
alex-straw Nov 11, 2023
47413c8
Use pydantic_settings, as this is current best practice. Update 2 oth…
alex-straw Nov 11, 2023
0e45fe1
Use pydantic_settings, as this is current best practice. Update 2 oth…
alex-straw Nov 11, 2023
440ad45
Handle merge conflicts + introduce get_openai_client in more places
alex-straw Nov 12, 2023
ee86fdc
Handle merge conflicts + introduce get_openai_client in more places
alex-straw Nov 12, 2023
e7a2e20
Merge pull request #76 from alex-straw/feature/centralise-openai-clie…
daveshap Nov 12, 2023
6c11f25
Merge pull request #76 from alex-straw/feature/centralise-openai-clie…
daveshap Nov 12, 2023
c2bf239
Add 'gpts' folder with .md files for GPT definitions
TKasperczyk Nov 12, 2023
34b80f8
Add 'gpts' folder with .md files for GPT definitions
TKasperczyk Nov 12, 2023
81789ec
Update README.md
daveshap Nov 12, 2023
a9b2d37
Update README.md
daveshap Nov 12, 2023
d7775bb
Update README.md
daveshap Nov 12, 2023
2d6f67e
Update README.md
daveshap Nov 12, 2023
6c05a87
Fixed the directory structure - moved `gpts` into `agents`
TKasperczyk Nov 12, 2023
37da791
Fixed the directory structure - moved `gpts` into `agents`
TKasperczyk Nov 12, 2023
2ac81bd
Merge pull request #106 from TKasperczyk/main
daveshap Nov 12, 2023
803cb20
Merge pull request #106 from TKasperczyk/main
daveshap Nov 12, 2023
e89164f
Fix conflicts
Nov 12, 2023
8fd416f
Fix conflicts
Nov 12, 2023
bcc63ca
Merge pull request #2 from guillermo-delrio/feature/agent_functions
guillermo-delrio Nov 12, 2023
38e387c
Merge pull request #2 from guillermo-delrio/feature/agent_functions
guillermo-delrio Nov 12, 2023
650a585
First prototype for github extension
romangoempire Nov 12, 2023
4daf2df
First prototype for github extension
romangoempire Nov 12, 2023
2d477f8
Document agent functions
Nov 12, 2023
21b0d60
Document agent functions
Nov 12, 2023
e60439f
Reorder
Nov 12, 2023
e32f86e
Reorder
Nov 12, 2023
b4ee0df
Merge pull request #3 from guillermo-delrio/feature/agent_functions
guillermo-delrio Nov 12, 2023
131538e
Merge pull request #3 from guillermo-delrio/feature/agent_functions
guillermo-delrio Nov 12, 2023
df29bcf
created README.md
romangoempire Nov 12, 2023
3343cea
created README.md
romangoempire Nov 12, 2023
2bbda36
Refactor get_pull_requests method to return only
romangoempire Nov 12, 2023
d1411f4
Refactor get_pull_requests method to return only
romangoempire Nov 12, 2023
f47821e
Merge pull request #112 from guillermo-delrio/main
guillermo-delrio Nov 12, 2023
178b510
Merge pull request #112 from guillermo-delrio/main
guillermo-delrio Nov 12, 2023
81a1af1
Merge branch 'daveshap:main' into dev
romangoempire Nov 12, 2023
243aee3
Merge branch 'daveshap:main' into dev
romangoempire Nov 12, 2023
3eebafc
cleaned up jupyter notebook and updated readme
romangoempire Nov 12, 2023
be0ecfa
cleaned up jupyter notebook and updated readme
romangoempire Nov 12, 2023
8aac317
Merge branch 'dev' of https://github.com/RomanGoEmpire/OpenAI_Agent_S…
romangoempire Nov 12, 2023
dd6c8af
Merge branch 'dev' of https://github.com/RomanGoEmpire/OpenAI_Agent_S…
romangoempire Nov 12, 2023
116e01c
Moving some agent creation call outside of the tool_maker folder and …
FireMMDC Nov 13, 2023
7762e95
Merge remote-tracking branch 'upstream/main' into tool-maker-tool-lookup
FireMMDC Nov 13, 2023
e080f4c
Transforming OpenAI function structures back into the JSON format for…
FireMMDC Nov 13, 2023
e5497ff
Fixed function def in settings.json, attempting to make instructions …
FireMMDC Nov 13, 2023
a8c4a50
Merge pull request #113 from RomanGoEmpire/dev
daveshap Nov 13, 2023
49e9235
Merge pull request #113 from RomanGoEmpire/dev
daveshap Nov 13, 2023
5ce33b9
Update README.md
daveshap Nov 13, 2023
3a4016d
Update README.md
daveshap Nov 13, 2023
285223d
Merge branch 'main' of https://github.com/daveshap/OpenAI_Agent_Swarm…
FireMMDC Nov 14, 2023
58de989
Refining temporary_function_writer instructions, removed additional i…
FireMMDC Nov 14, 2023
8c82bd2
Add thread locking
GeorgiaPhillips1008 Nov 14, 2023
e3781b1
Update README.md
Ruijian-Zha Nov 14, 2023
472d7a4
Update README.md
Ruijian-Zha Nov 14, 2023
6d54571
Merge pull request #142 from Ruijian-Zha/main
romangoempire Nov 14, 2023
c90abad
Merge pull request #142 from Ruijian-Zha/main
romangoempire Nov 14, 2023
e1c281c
Adding discord_comms.py code from Google Colab experimentation, as we…
Starblaiz Nov 15, 2023
c6d7480
Readding discord.py code due to an issue
Starblaiz Nov 15, 2023
9b1b977
Added extra TODO to README.md
Starblaiz Nov 15, 2023
3852501
Merge remote-tracking branch 'upstream/main'
Starblaiz Nov 15, 2023
564c084
Converted code to a class for better encapsulation. Split the setting…
Starblaiz Nov 15, 2023
3727adb
Resistance is - and always has been - futile.
Starblaiz Nov 15, 2023
50f303f
Updates documentation with a few tweaks
Starblaiz Nov 15, 2023
8a2ae3d
Update HAAS_Documentation.md
gantagonist Nov 15, 2023
58f1cee
Update HAAS_Documentation.md
gantagonist Nov 15, 2023
e2e512f
Merge pull request #155 from gantagonist/main
daveshap Nov 15, 2023
df96e2a
Merge pull request #141 from guillermo-delrio/lock-threads
daveshap Nov 15, 2023
62d898a
Fix: Correct markdown for DEMO.png and OpenAI_Tools.PNG in tool_maker…
nyirocsaba Nov 15, 2023
cce3231
Merge pull request #156 from nyirocsaba/patch-1
daveshap Nov 15, 2023
44559bc
Merge pull request #154 from Starblaiz/main
daveshap Nov 15, 2023
1b634e6
Correcting typos
FireMMDC Nov 16, 2023
8af5f6f
Cleanup of the manual tests for assistants
guillermo-delrio Nov 16, 2023
d71643e
Rename for consistency
guillermo-delrio Nov 16, 2023
fd846eb
Merge pull request #160 from daveshap/feature/cleanup-assistants-tests
guillermo-delrio Nov 17, 2023
35c03d4
Add hints for Agent's properties
guillermo-delrio Nov 17, 2023
ef3fee0
Move innitial message to YAML
guillermo-delrio Nov 17, 2023
edf1137
Load assistant's IDs from separate env file
guillermo-delrio Nov 17, 2023
f53ea73
Fix typo
guillermo-delrio Nov 17, 2023
4ce858f
Update contributing.md
daveshap Nov 17, 2023
61c6bd3
Add req.txt and update parameer name
guillermo-delrio Nov 19, 2023
e09e141
Update readme
guillermo-delrio Nov 19, 2023
ebb7ba3
Automate the creation of assistants based off the definition files
guillermo-delrio Nov 20, 2023
8894a5f
Improve pending action handling
guillermo-delrio Nov 20, 2023
ad34859
Fix typo
guillermo-delrio Nov 21, 2023
10c58e3
Fix module
Nov 21, 2023
1770774
add logging class, integrate HTTP POST to debug interface
thehunmonkgroup Nov 22, 2023
1ef84f6
Merge pull request #168 from daveshap/feature/manual-assistants-impro…
guillermo-delrio Nov 23, 2023
a55afbd
Merge pull request #172 from thehunmonkgroup/feature/manual-assistant…
guillermo-delrio Nov 23, 2023
9c6de72
refactor function handling
thehunmonkgroup Nov 24, 2023
c6278c1
Merge pull request #176 from thehunmonkgroup/feature/manual-assistant…
thehunmonkgroup Nov 25, 2023
d5a3216
properly check for existence of langchain tools
thehunmonkgroup Nov 26, 2023
7ffc9d2
convert OAIWrapper to class, add agent update support
thehunmonkgroup Nov 26, 2023
055d6ae
refactor how tools return output, improve logging for tool calls
thehunmonkgroup Nov 26, 2023
86067c3
Merge pull request #179 from thehunmonkgroup/feature/manual-assistant…
thehunmonkgroup Nov 26, 2023
e685ca4
pass toolList as extra arg to log
thehunmonkgroup Nov 26, 2023
4b0a1e6
fix tool documentation
thehunmonkgroup Nov 26, 2023
d674c04
Merge pull request #180 from thehunmonkgroup/feature/manual-assistant…
thehunmonkgroup Nov 26, 2023
b839c93
update link to langchain tool integrations
thehunmonkgroup Nov 26, 2023
a076edb
Merge pull request #181 from thehunmonkgroup/manual-assistants-doc-fix
thehunmonkgroup Nov 26, 2023
365f19e
tweak log message
thehunmonkgroup Nov 28, 2023
dad607e
refactor agent create/update, set tools in update
thehunmonkgroup Nov 28, 2023
b154a52
Pool rules agent definition
thehunmonkgroup Nov 28, 2023
13f2679
Merge pull request #185 from daveshap/manual-assistants-pool-rules
thehunmonkgroup Nov 28, 2023
ff12381
Path fixes and readme update
OWigginsHay Nov 29, 2023
788efa4
Merge remote-tracking branch 'upstream/main'
OWigginsHay Nov 29, 2023
983ef72
Merge pull request #188 from OWigginsHay/main
OWigginsHay Nov 29, 2023
6e9d225
Resolving merge conlicts for PR
FireMMDC Nov 30, 2023
e2d761b
Merge pull request #135 from FireMMDC/tool-maker-tool-lookup
OWigginsHay Nov 30, 2023
e862a1f
Reworking create.py into a class, adding the ability to create a spec…
FireMMDC Nov 30, 2023
38e7608
Merge branch 'main' into tool-maker-tool-lookup
FireMMDC Nov 30, 2023
825ddae
Adding an error message, if a specific agent name does not exist in t…
FireMMDC Nov 30, 2023
01f275f
Removing test code
FireMMDC Nov 30, 2023
4b627d3
adding mission
daveshap Nov 30, 2023
fede95f
Adding pathing for module, removing stary charcater
FireMMDC Nov 30, 2023
40bec6a
implement Jinja template manager, template agent instructions
thehunmonkgroup Dec 1, 2023
140a9dc
clean up dead files
thehunmonkgroup Dec 1, 2023
1b24ba7
add to README
thehunmonkgroup Dec 1, 2023
4238247
Merge pull request #196 from daveshap/feature/manual-assistants-templ…
thehunmonkgroup Dec 1, 2023
37bd375
Merge pull request #195 from FireMMDC/temp-file-pathing
romangoempire Dec 6, 2023
fbf5cd4
Resolving Merge Conflict, including path look up within create_assist…
FireMMDC Dec 6, 2023
020b44e
Merge pull request #191 from FireMMDC/tool-maker-tool-lookup
OWigginsHay Dec 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
key_openai.txt
/**/*/.env
/**/*/.env
*.pyc
/**/*/agentsIds.env
/**/*/__pycache__
.vscode
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,33 @@
We have our first GPT Concierge. You can chat with this custom ChatGPT to figure out what's going on!

- **HAAS Board Concierge:** [https://chat.openai.com/g/g-MIssTuE2b-haas-board-concierge](https://chat.openai.com/g/g-MIssTuE2b-haas-board-concierge)
- **HAAS Assistant:** [https://chat.openai.com/g/g-lIAp9qowx-haas-assistant](https://chat.openai.com/g/g-lIAp9qowx-haas-assistant) (Similar function as above but markedly faster)

## Overview
## Public Discord

The Autonomous AI Lab discord for the ACE Framework and HAAS Project is now open: https://discord.gg/mJKUYNm8qY

> !!!! IMPORTANT NOTE: This repo is still the single source of truth! If it's not on this repo, it doesn't exist! Discord is merely for convenience.

# Project Principles

## Move Fast, Break Stuff

This is first and foremost a high velocity hacking group.

## Cutting Edge Only

Exclusively use cutting edge stuff, like OpenAI's latest Agents endpoint. For exclusively Open Source, go check out the ACE Framework: https://github.com/daveshap/ACE_Framework

## Full Autonomy

Fully autonomous swarms are the goal. That means a human does not need to be in the loop telling it what to do, supervising, or anything. Characteristics of a fully autonomous swarm:

1. **Self-Directing:** Once instantiated, the swarm pursues its mission or goals without supervision. It may self-direct based on principles such as the heuristic imperatives, or by specific mission parameters.
2. **Self-Correcting:** The swarm must detect and correct technical, strategic, epistemic, and other errors and then correct them.
3. **Self-Improving:** Eventually, the swarm should enhance its own fundamental capabilities over time.

# Overview

The Hierarchical Autonomous Agent Swarm (HAAS) is a groundbreaking initiative that leverages OpenAI's latest advancements in agent-based APIs to create a self-organizing and ethically governed ecosystem of AI agents. Drawing inspiration from the ACE Framework, HAAS introduces a novel approach to AI governance and operation, where a hierarchy of specialized agents, each with distinct roles and capabilities, collaborate to solve complex problems and perform a wide array of tasks.

Expand Down
59 changes: 0 additions & 59 deletions agent_builder/create.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"model": "gpt-4-1106-preview",
"description": "Foundation Swarm Builder",
"tools": [{ "type": "code_interpreter" }],
"metadata": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Mission
- You will be provided JSON schema of an OpenAI function tool from an API and not a human user
- The JSON will contain all information about the function and you will need to translate it into a python function.

# Background info
- None

# Rules
- Your response must only be a python markdown block containing the translated function
- The function must be fully implemented in python
- The function should not contain pseudo code or placeholders

# Instructions
- Translate the JSON to a fully functioning python function
- Return the python function in a markdown block
- If you are unable to perform this translation return reply asking for additional info as arguments
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"model": "gpt-4-1106-preview",
"description": "Function writer",
"tools": [
{ "type": "code_interpreter" },
{
"type": "function",
"function": {
"name": "get_existing_functions",
"description": "List available functions that can be called",
"parameters": { "type": "object", "properties": {} },
"required": []
}
}
],
"metadata": {}
}
34 changes: 34 additions & 0 deletions agents/agent_builder/agents/tool_creator/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Mission
- Transcript a user's request into a valid schema to represent a valid function call

# Background info
None

# Rules
- Always check the provided files to ground your thoughts.
- If a term can have multiple meanings, always prefer those mentioned in the provided documents.

# Instructions
- Initialize: Prepare to receive input for the creation of a new function using the request_function tool.
- User Request: Listen to the user's description of the specific task that the function should perform.
- Function Name:
a. Derived from the task description, formulate a concise and descriptive function name.
b. Aim for clarity and specificity to convey the function's purpose effectively.
- Function Description:
a. Write a clear and precise description of the function's expected behavior.
b. Include details about what the function will accomplish and any side effects.
c. (Emphasize) Ensure that the description explicitly communicates the function's intended outcome to avoid ambiguity.
- Input Arguments JSON Schema:
a. Based on the requirements of the task, define the JSON schema for the input arguments.
b. The schema should be comprehensive and must specify the types, required fields, and constraints for each input argument.
c. Ensure that the schema aligns with the user's requirements and the function's intended behavior.
- Validation: Cross-check the name, description, and JSON schema against the user's requirements to confirm accuracy and completeness.
- Execution: Utilize the request_function tool with the following
inputs:
name: [Function Name]
descriptions: [Function Description]
input_argument_json_schema: [Input Arguments JSON Schema]
- Feedback Loop: Promptly present the newly created function specifications to the user for any feedback or necessary revisions.
- Iterate: Make adjustments as requested by the user, refining the function name, description, and input argument schema until it meets the user's satisfaction.
Finalize: Once the user gives approval, consider the function creation process complete.
- Note: Remember to prioritize user requirements and emphasize clear communication in the function description, as highlighted by the user.
33 changes: 33 additions & 0 deletions agents/agent_builder/agents/tool_creator/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"model": "gpt-4-1106-preview",
"description": "assistant to demonstrate tool creation",
"tools": [
{ "type": "code_interpreter" },
{
"type": "function",
"function": {
"name": "function_request",
"description": "request an authority to grant you access to a new function",
"parameters": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "name of the function"
},
"description": {
"type": "string",
"description": "expected function behaviour"
},
"schema": {
"type": "string",
"description": "the input arguments for the requested function following the JOSN schema in a format ready to be serialized"
}
},
"required": ["name", "schema"]
}
}
}
],
"metadata": {}
}
164 changes: 164 additions & 0 deletions agents/agent_builder/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import os
import json
from pathlib import Path
from shared.openai_config import get_openai_client

class AgentBuilder:

def __init__(self,client):
self.client = client
self.existing_assistants = {}
self.agents_path = "agents"

def get_existing_assistants(self):
if not self.existing_assistants:
for assistant in self.client.beta.assistants.list(limit=100):
self.existing_assistants[assistant.name] = assistant

def create_assistant(self, agent_name):
current_file_path = Path(__file__).absolute().parent
agent_folder = os.path.join(current_file_path, self.agents_path, agent_name)

if (
not os.path.exists(agent_folder)
or not os.path.isdir(agent_folder)
or not os.listdir(agent_folder)
):
raise ValueError(f'{agent_folder} is missing, not a directory, or empty.')

print(agent_folder)
existing_files = {}
requested_files = []
existing_agent = {}
self.get_existing_assistants()
if agent_name in self.existing_assistants:
existing_agent = self.existing_assistants[agent_name]
for file_id in existing_agent.file_ids:
existing_file = self.client.files.retrieve(file_id=file_id)
existing_files[existing_file.filename] = existing_file


if os.path.isdir(agent_folder):
# Read contents from the 'instructions.md' file
instructions = ""
instructions_file_path = os.path.join(agent_folder, "instructions.md")
if os.path.isfile(instructions_file_path):
with open(instructions_file_path, 'r') as f:
instructions = f.read()

# Read contents from the 'settings.json' file
settings = {}
settings_file_path = os.path.join(agent_folder, 'settings.json')
if os.path.isfile(settings_file_path):
with open(settings_file_path, 'r') as f:
settings = json.load(f)

# Check for the 'files' subfolder and process its contents
files = []
files_folder = os.path.join(agent_folder, 'files')
if os.path.isdir(files_folder):
for filename in os.listdir(files_folder):
requested_files.append(filename)
# Doesn't handle if file has been modified
if filename not in existing_files:
file_path = os.path.join(files_folder, filename)
with open(file_path, 'rb') as file_data:
# Upload each file to OpenAI
file_object = self.client.files.create(
file=file_data, purpose='assistants'
)
files.append({"name": filename, "id": file_object.id})

print(agent_name)
print("")
print(instructions)
if files:
print("")
print(f"Files: {list(map(lambda x: x['name'], files))}")

assistant={}

if existing_agent:
print(f"{agent_name} already exists... validating properties")
update_model = existing_agent.model != settings["model"]
update_description = existing_agent.description != settings["description"]
update_instructions = existing_agent.instructions != instructions
existing_agent_tools_raw = list(filter(lambda item: item.type == "function", existing_agent.tools))
existing_agent_tools = [ ({ 'type': item.type, 'function': { 'name': item.function.name, 'description': item.function.description, 'parameters': item.function.parameters } }) for item in existing_agent_tools_raw ]
setting_agent_tools = list(filter(lambda item: item["type"] == "function", settings["tools"]))
update_tools = existing_agent_tools != setting_agent_tools

update_params = {}

requested_files_set = set(requested_files)
existing_files_set = set(existing_files.keys())

if update_model:
update_params["model"] = settings["model"]
if update_instructions:
update_params["instructions"] = instructions
if update_description:
update_params["description"] = settings["description"]
if files or requested_files_set != existing_files_set:
retained_set = existing_files_set.intersection(requested_files_set)
all_file_ids = []
for key in retained_set:
all_file_ids.append(existing_files[key].id)
all_file_ids += list(map(lambda x: x['id'], files))
update_params['file_ids'] = all_file_ids
if not any( tool.type == "retrieval" for tool in existing_agent.tools):
update_params['tools'] = existing_agent.tools
update_params['tools'].append({'type': 'retrieval'})
if update_tools:
update_params['tools'] = settings["tools"]
if len(requested_files) > 0:
update_params['tools'].append({'type': 'retrieval'})

if len(update_params) != 0:
print(f"Updating {agent_name}'s { ','.join(update_params.keys()) }")
update_params['assistant_id'] = existing_agent.id
assistant = self.client.beta.assistants.update(**update_params)
else:
print(f"{agent_name} is up to date")
else:

create_params = {
"name": agent_name,
"instructions": instructions,
"description": settings["description"],
"model": settings["model"],
"tools": settings["tools"]
}

# Only include 'file_ids' if there are files
if files:
create_params['tools'].append({'type': 'retrieval'})
create_params['file_ids'] = list(map(lambda x: x['id'], files))

# Create the assistant using the uploaded file IDs if files exist
assistant = self.client.beta.assistants.create(**create_params)
print("***********************************************")

def create_assistants(self):
agents_path = os.path.join(
Path(__file__).absolute().parent, self.agents_path
)

# Check if the 'agents' folder is empty or doesn't exist
if (
not os.path.exists(agents_path)
or not os.path.isdir(agents_path)
or not os.listdir(agents_path)
):
raise ValueError(f'The "{self.agents_path}" folder is missing, not a directory, or empty.')

self.get_existing_assistants()

# Iterate over each folder inside the 'agents' folder
for agent_name in os.listdir(agents_path):
self.create_assistant(agent_name)

if __name__ == '__main__':
client = get_openai_client()
agent_builder = AgentBuilder(client=client)
agent_builder.create_assistants()
Loading