A package for building intelligent agents through OpenAI's API.
Project description
Personal Project: AI Agent Framework
A modular and extensible framework for building AI agents capable of interacting with users, managing tools, and delegating tasks to helper agents. The project is designed for flexibility, maintainability, and ease of integration with tools.
Key Features
- Agent Class: A self-sufficient AI agent with chat capabilities, history management, and tool integration.
- ToolBox: A utility for registering and managing tools with strict JSON schemas.
- Multi-Agent Systems: Agents can delegate tasks to other helper agents, enabling complex workflows and collaborative problem-solving.
- Extensibility: Easily add new tools, including to integrate with external APIs.
Repository Structure
-
agent.py- Implements the
Agentclass, which serves as the core of the framework. - Features:
- Chat interface with history management using
deque. - Integration with tools and helper agents.
- Graceful handling of user interruptions (
KeyboardInterrupt). - Modularized helper-agent tool registration.
- Chat interface with history management using
- Implements the
-
tool_box.py- Provides the
ToolBoxclass for managing tools. - Features:
- Tool registration with JSON schema validation.
- Logging of tool calls and results.
- Support for merging multiple
ToolBoxinstances.
- Provides the
-
tools.py- A compilation of example tools for integration with the framework.
- Includes tools for tasks like managing Google Calendar events and sending emails.
Getting Started
Prerequisites
- Python 3.10 or higher
- Required Python packages (install via
pip):openaigoogle-authgoogle-auth-oauthlibgoogle-api-python-clientpython-dotenv
Installation
-
Clone the repository:
git clone https://github.com/lundmj/aiAgents.git cd aiAgents
-
Install dependencies:
pip install -r requirements.txt
main Usage
-
Run the agent with a system prompt:
python main.py system_prompts/calendar_assistant.md -t calendar_tool_box
-
Use the
-hflag for help:python main.py -h
Defining Your Own
- Agent
- Create an instance of the
Agentclass inagent.py.
- Create an instance of the
- Tool
- Import
ToolBoxinto the file in which you want to define tools (seetools.py). Create an instance of the tool box. - Write a function that you want your agent to be able to call.
- The parameters need to be strings or a numeric type.
- Annotate the types of the parameters, give the parameters clear names, and define a return type (typically
str). TheToolBoxwill enable the agent to read and understand this function signature. - Write a simple docstring explaining the functionality of the tool, using
"""notation.ToolBoxwill also help the agent read this as an explanation of the tool.
- Decorate the function with
@<tool_box>.toolto store the tool in the tool box.- Replace
<tool_box>with the variable name of your tool box.
- Replace
- Any number of tools can go in a tool box, and by stacking decorations, you can put a tool in any number of tool boxes.
- Import
Example Files
System Prompts
The system_prompts folder contins some example prompts to give an AI agent. These are what you provide a Path to when instantiating an agent.
Delegator Example
The file delegator.py is an example of three agents:
delegator_agentuses a reasoning model and has the other two agents provided to it as tools. It is instructed to simply carry out tasks, with knowledge that it may need to delegate. Notice that its system prompt contains no direction as to which agents it can delegate to; it deduces that from the agents it gets.calendar_agentandemail_agentare non-reasoning models (usinggpt-4.1) that are instructed to handle their various tasks. They are provided their own set of tools in their tool boxes, which are independent of each other and the delegator agent above them.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentics_lundmj-0.2.1.tar.gz.
File metadata
- Download URL: agentics_lundmj-0.2.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70619c3f8d5464cedb58da207a09ece53feae2e35ceb9a750734e1a2dbeccea4
|
|
| MD5 |
6d5bf4d24931ae08ed541178ba6dfe2a
|
|
| BLAKE2b-256 |
24b4bf4fe49e9094d40a8c5f60603fc35f88eaf4e5afb06755bb22e94b130801
|
File details
Details for the file agentics_lundmj-0.2.1-py3-none-any.whl.
File metadata
- Download URL: agentics_lundmj-0.2.1-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d20b49a140c54d82c902b3eca9fe71a2222828bb74d07f37bef0dd34d0674aba
|
|
| MD5 |
36bcafe6345ac7e0aea39ba88c884334
|
|
| BLAKE2b-256 |
dd0ea072ea5af5c533899af47e88529b911016f148f9e95501bc95ed5618857e
|