Skip to main content

Building blocks for AI Agents

Project description

AgentPress: Building Blocks for AI Agents

AgentPress is not a agent framework - it's a collection of lightweight, modular utilities that serve as building blocks for creating AI agents. Think of it as "shadcn/ui for AI agents" - a set of utils to copy, paste, and customize in order to quickly bootstrap your AI App / Agent.

AgentPress provides Messages[] API on Steroids called "Threads", a ThreadManager with automatic Tool Execution and a simple StateManager.

  • Threads: Simple message thread handling utilities
  • Automatic Tool: Flexible tool definition and automatic execution
  • State Management: Basic JSON-based state persistence
  • LLM Integration: Provider-agnostic LLM calls via LiteLLM

Installation & Setup

  1. Install the package:
pip install agentpress
  1. Initialize AgentPress in your project:
agentpress init

This will create a agentpress directory with the core utilities you can customize.

  1. If you selected the example agent during initialization:
    • Creates an agent.py file with a web development agent example
    • Creates a tools directory with example tools:
      • files_tool.py: File operations (create/update files, read directory and load into state)
      • terminal_tool.py: Terminal command execution
    • Creates a workspace directory for the agent to work in

Quick Start

  1. Set up your environment variables (API keys, etc.) in a .env file.
  • OPENAI_API_KEY= ANTHROPIC_API_KEY= GROQ_API_KEY= Whatever LLM you want to use, we use LiteLLM (Call 100+ LLMs using the OpenAI Input/Output Format) https://docs.litellm.ai/ – set it up in your .env file.. Also check out the agentpress/llm.py and modify as needed to support your wanted LLM.
  1. Create a calculator_tool.py
from agentpress.tool import Tool, ToolResult, tool_schema

class CalculatorTool(Tool):
    @tool_schema({
        "name": "add",
        "description": "Add two numbers",
        "parameters": {
            "type": "object",
            "properties": {
                "a": {"type": "number"},
                "b": {"type": "number"}
            },
            "required": ["a", "b"]
        }
    })
    async def add(self, a: float, b: float) -> ToolResult:
        try:
            result = a + b
            return self.success_response(f"The sum is {result}")
        except Exception as e:
            return self.fail_response(f"Failed to add numbers: {str(e)}")
  1. Use the Thread Manager, create a new thread – or access an existing one. Then Add the Calculator Tool, and run the thread. It will automatically use & execute the python function associated with the tool:
import asyncio
from agentpress.thread_manager import ThreadManager
from calculator_tool import CalculatorTool

async def main():
    # Initialize thread manager and add tools
    manager = ThreadManager()
    manager.add_tool(CalculatorTool)

    # Create a new thread
    # Alternatively, you could use an existing thread_id like:
    # thread_id = "existing-thread-uuid" 
    thread_id = await manager.create_thread()
    
    # Add your custom logic here
    await manager.add_message(thread_id, {
        "role": "user", 
        "content": "What's 2 + 2?"
    })
    
    response = await manager.run_thread(
        thread_id=thread_id,
        system_message={
            "role": "system", 
            "content": "You are a helpful assistant with calculation abilities."
        },
        model_name="gpt-4",
        use_tools=True,
        execute_model_tool_calls=True
    )
    print("Response:", response)

asyncio.run(main())
  1. Autonomous Web Developer Agent (the standard example)

When you run agentpress init and select the example agent – you will get code for a simple implementation of an AI Web Developer Agent that leverages architecture similar to platforms like Softgen, Bolt, GPT Engineer, V0, etc...

  • Files Tool: Allows the agent to create, read, update, and delete files within the workspace.
  • Terminal Tool: Enables the agent to execute terminal commands.
  • State Workspace Management: The agent has access to a workspace whose state is stored and sent on every request. This state includes all file contents, ensuring the agent knows what it is editing.
  • User Interaction via CLI: After each action, the agent pauses and allows the user to provide further instructions through the CLI.

You can find the complete implementation in our example-agent directory.

Development

  1. Clone for reference:
git clone https://github.com/kortix-ai/agentpress
cd agentpress
  1. Install dependencies:
pip install poetry
poetry install

Philosophy

  • Modular: Pick and choose what you need. Each component is designed to work independently.
  • Agnostic: Built on LiteLLM, supporting any LLM provider. Minimal opinions, maximum flexibility.
  • Simplicity: Clean, readable code that's easy to understand and modify.
  • Plug & Play: Start with our defaults, then customize to your needs.
  • No Lock-in: Take full ownership of the code. Copy what you need directly into your codebase.

Contributing

We welcome contributions! Feel free to:

  • Submit issues for bugs or suggestions
  • Fork the repository and send pull requests
  • Share how you've used AgentPress in your projects

License

MIT License

Built with ❤️ by Kortix AI Corp

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

agentpress-0.1.2.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpress-0.1.2-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file agentpress-0.1.2.tar.gz.

File metadata

  • Download URL: agentpress-0.1.2.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for agentpress-0.1.2.tar.gz
Algorithm Hash digest
SHA256 519c089dce7d71016b5385199ac635283e9dfb2d0fbe07e6e318d751df3737ce
MD5 4cfaf966be0bd13de3175bcb41bc90c0
BLAKE2b-256 e47a27df30d5cab7b8bdfdd9e718b5a4e11f13fcc2efdec6a9b7c1afdf8bc83d

See more details on using hashes here.

File details

Details for the file agentpress-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: agentpress-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure

File hashes

Hashes for agentpress-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a8be6d05e5ee13294a547ac9f304a679d6db0f61884173278e2d0776cfa70f2
MD5 2556348a9174362be21ad5e3451becc2
BLAKE2b-256 9d98400e2c3c33d8c280b13b006d2da218dd51dce61d74e8464942f2a8b4e880

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page