2024-10-06 01:04:15 +08:00
# agentpress
2024-10-06 01:01:40 +08:00
2024-10-18 23:38:00 +08:00
AgentPress simplifies the process of creating AI agents by providing a robust thread management system and a flexible tool integration mechanism. With AgentPress, you can easily create, configure, and run AI agents that can engage in conversations, perform tasks, and interact with various tools.
2024-10-06 01:01:40 +08:00
### Key Features
2024-10-18 23:38:00 +08:00
- **Thread Management System**: Manage conversations and task executions through a sophisticated thread system.
- **Flexible Tool Integration**: Easily integrate and use custom tools within your AI agents.
- **Configurable Agent Behavior**: Fine-tune your agent's behavior with customizable settings and callbacks.
- **Autonomous Iterations**: Allow your agent to run multiple iterations autonomously.
- **State Management**: Control your agent's behavior at different stages of execution.
2024-10-06 01:01:40 +08:00
### Getting Started
2024-10-18 23:38:00 +08:00
To get started with AgentPress, all you need to do is write your agent similar to the example in `agent.py` . Here's a basic outline:
1. Import necessary modules:
```python
from agentpress.db import Database
from agentpress.thread_manager import ThreadManager
from tools.files_tool import FilesTool
```
2. Create a ThreadManager instance:
```python
db = Database()
manager = ThreadManager(db)
```
3. Set up your agent's configuration:
```python
settings = {
"thread_id": thread_id,
"system_message": system_message,
"model_name": "gpt-4",
"temperature": 0.7,
"max_tokens": 150,
"autonomous_iterations_amount": 3,
"continue_instructions": "Continue the conversation...",
"tools": list(tool_schemas.keys()),
"tool_choice": "auto"
}
```
4. Define callback functions (optional):
```python
def initializer():
# Code to run at the start of the thread
def pre_iteration():
# Code to run before each iteration
def after_iteration():
# Code to run after each iteration
def finalizer():
# Code to run at the end of the thread
```
5. Run your agent:
```python
response = await manager.run_thread(settings)
```
2024-10-06 01:01:40 +08:00
### Documentation
2024-10-18 23:38:00 +08:00
The core of AgentPress is the `ThreadManager` class in `thread_manager.py` . It provides a comprehensive thread management system where you can:
2024-10-06 01:01:40 +08:00
2024-10-18 23:38:00 +08:00
- Create and manage threads
- Add messages to threads
- Run threads with specific settings
- Configure autonomous iterations
- Integrate and use tools
2024-10-06 01:01:40 +08:00
2024-10-18 23:38:00 +08:00
Tools in AgentPress are based on the `Tool` class defined in `tool.py` . You can create custom tools by inheriting from this class and implementing the required methods. An example is the `FilesTool` in `files_tool.py` .
2024-10-06 01:01:40 +08:00
2024-10-18 23:38:00 +08:00
For more detailed documentation, please refer to the comments in the source code files.
2024-10-06 01:01:40 +08:00
2024-10-18 23:38:00 +08:00
Built with ❤️ by [Kortix AI Corp ](https://www.kortix.ai )