Skip to main content

A lightweight Python AI agent framework for building autonomous agents.

Project description

Iris Agent Framework

A lightweight Python AI agent framework for building autonomous agents.

Features

  • 🤖 Simple Agent Interface - Easy-to-use sync and async agent classes
  • 🛠️ Tool Decorators - Expose Python functions as LLM tools with automatic schema inference
  • 🔌 Provider Agnostic - Support for OpenAI, Google Gemini, and more
  • 📝 Code-Defined Prompts - Manage prompts in code, no database needed
  • 🎨 Rich Logging - Beautiful step-by-step logging with Rich
  • 🔄 Streaming Support - Built-in streaming for real-time responses
  • Type Safe - Full type hints and validation

Installation

From PyPI

pip install iris-agent

From source

git clone https://github.com/yourusername/iris-agent.git
cd iris-agent
pip install -e .

Quick Start

from iris_agent import (
    Agent,
    LLMConfig,
    LLMProvider,
    SyncLLMClient,
    PromptRegistry,
    ToolRegistry,
    tool,
)

prompts = PromptRegistry()
prompts.add_prompt("assistant", "You are a helpful assistant.")

tools = ToolRegistry()

@tool(description="Add two numbers.")
def add(a: int, b: int) -> int:
    return a + b

tools.register(add)

client = SyncLLMClient(
    LLMConfig(
        provider=LLMProvider.OPENAI,
        model="gpt-4o-mini",
        api_key="sk-...",
    )
)

agent = Agent(
    llm_client=client,
    prompt_registry=prompts,
    tool_registry=tools,
)

response = agent.run("What is 2 + 3?")
print(response)

Sync Streaming

agent = Agent(llm_client=client)

for chunk in agent.run_stream("Tell me a short story."):
    print(chunk, end="", flush=True)
print()

Tool Decorators

Use @tool to expose any function as a tool. The framework will infer a JSON schema from function annotations, or you can pass a schema explicitly.

@tool(name="search_web", description="Search the web", parameters={...})
def search_web(query: str) -> str:
    ...

Prompt Registry

Define prompts in code:

prompts = PromptRegistry()
prompts.add_prompt("assistant", "You are an expert travel planner.")

System Prompts

System prompts control the agent's behavior and personality. You can add them as simple strings or dynamic callables:

# Simple string prompt
prompts = PromptRegistry()
prompts.add_prompt("assistant", "You are a helpful AI assistant.")

# Dynamic prompt with parameters
prompts.add_prompt(
    "customer_support",
    lambda user_name: f"You are a customer support agent for {user_name}."
)

# Multiple prompts for different agent types
prompts.add_prompt("coder", "You are an expert Python programmer.")
prompts.add_prompt("writer", "You are a creative writing assistant.")

# Create agent with specific prompt
agent = Agent(
    llm_client=client,
    prompt_registry=prompts,
    system_prompt_name="coder"  # Uses the "coder" prompt
)

See examples/system_prompt_example.py for more detailed examples.

Documentation

The project documentation is available on:

  • https://mrgehlot.github.io/iris-agent/

Providers

LLMConfig supports multiple providers:

  • OpenAI
  • Google Gemini
  • Additional providers can be added by implementing a custom client based on BaseLLMClient.

Logging (Rich)

You can enable step-by-step agent logging using the rich package:

agent = Agent(
    llm_client=client,
    prompt_registry=prompts,
    tool_registry=tools,
    enable_logging=True,
)

Rich logging is included by default.

Testing

Run the test suite:

# Install dev dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run only unit tests (skip integration tests that require API keys)
pytest -m "not integration"

# Run only integration tests (requires OPENAI_API_KEY)
pytest -m integration

# Run with coverage
pytest --cov=iris_agent --cov-report=html

Development

  1. Clone the repository
  2. Install in editable mode: pip install -e ".[dev]"
  3. Make your changes
  4. Run tests: pytest
  5. Format code: black . and isort .

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

iris_agent-0.1.3.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

iris_agent-0.1.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file iris_agent-0.1.3.tar.gz.

File metadata

  • Download URL: iris_agent-0.1.3.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for iris_agent-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5d1be4a600d17acb9b999ed5307831d505e9b34b7a0e86759bebbb0493906024
MD5 cc60a46d3f612a2273a1b7d8df72db34
BLAKE2b-256 4a87b43b994cdd72a6a2a636aa858c6c460751744003adb6e03314cb94be29ea

See more details on using hashes here.

File details

Details for the file iris_agent-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: iris_agent-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for iris_agent-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4bbb43803a282ff9e09ba03ebca716b5c442e786dfb8dede8761943304726d47
MD5 5abc830b7aa145fe11a01d768b304d1e
BLAKE2b-256 9522152a95522830c785fe2d9968ed8549d8eada416d155b272f7a00e2aec6e1

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