Skip to main content

AAF (Agentic AI Framework)

AAF is a versatile and extensible framework for building and managing agentic AI models. It provides a unified interface for various language model providers and implements advanced virtual models for complex, agent-like conversational scenarios.

Note that AAF is primarily a personal learning project focused on exploring agentic AI and LLM use, including complex multi-step interactions. While it can be useful for actual use cases like autonomous chat agents and multi-stage task completion, please exercise caution when considering it for anything even remotely important.

Features

  • Support for multiple LLM providers (OpenAI, Anthropic, Ollama, LiteLLM) to act as the foundation for AI agents
  • Advanced conversation management with Threads and Sessions for maintaining agent state
  • Virtual models for complex, multi-step agent behaviors:
    • TwoPhase: For agents that plan before acting
    • Multiphase: For agents that can break down and tackle complex tasks
    • Router: For meta-agents that can delegate to specialized sub-agents
  • Tool integration for function calling capabilities
  • Cost and token usage tracking

Installation

pip install aaf

Quick Start

from aaf.threads import Session

thread = Session().create_thread("gpt-4o", system="You are a helpful assistant.")
thread.add_message("user", "What is the capital of France?")

async with thread.run() as stream:
    async for chunk in stream.text_chunks():
        print(chunk.content, end="", flush=True)
    print()

print(thread.cost_and_usage().pretty())

Usage

LLM Providers

AAF supports multiple LLM providers. To use a specific provider, specify the model name when creating a thread:

thread = session.create_thread("gpt-4o")  # OpenAI
thread = session.create_thread("claude-3-5-sonnet-20240620")  # Anthropic
thread = session.create_thread("llama3.1:8b")  # Ollama

Virtual Models

AAF implements several virtual models for advanced use cases:

  • TwoPhase: Generates a prompt and then uses it to create a response
  • Multiphase: Multi-step process for complex questions, including drafting, feedback, and refinement
  • Router: Selects the appropriate model based on the user's request

Using a virtual model is same as with standard models:

from aaf.virtual_models.two_phase import TwoPhaseModel
from aaf.threads import Session

thread = Session().create_thread(model="two-phase", runner=TwoPhaseModel())
thread.add_message("user", "What is the capital of France?")

async with thread.run() as stream:
    async for chunk in stream.text_chunks():
        print(chunk.content, end="", flush=True)
    print()

print(thread.cost_and_usage().pretty())

Project Structure

  • aaf/: Main package directory
    • llms/: LLM provider implementations
    • virtual_models/: Virtual model implementations
    • tools/: Tool definitions
    • threads.py: Thread and Session management
    • logging.py: Custom logging implementation
    • utils.py: Utility functions

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for aaf 0.3.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aaf 0.3.10
File Size Uploaded Provenance
aaf-0.3.10.tar.gz 106.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aaf 0.3.10
File Interpreter ABI Platform
aaf-0.3.10-py3-none-any.whl Python 3 none any Details

Total release size: 146.1 kB

Release files / aaf-0.3.10.tar.gz

Download URL aaf-0.3.10.tar.gz
Size 106.3 kB
Tags Source
SHA-256 checksum
How to use checksums
06c6c12adbbde9454f3ac0a0129b55a8de4f97ee4c0ab221b2f40316a4f15d9a
BLAKE2b-256 checksum
How to use checksums
7f31b03da483a7eadc4dde88b90142cf7171160c42c8f57c50d1a722892a84ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / aaf-0.3.10-py3-none-any.whl

Download URL aaf-0.3.10-py3-none-any.whl
Size 39.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f13df070b21f12a25486b4227ae1f6a6f21b8bb57d5c39d37259743a73890fdf
BLAKE2b-256 checksum
How to use checksums
f05d31c051e1313db343cc516e45dada9d8adf734ba9688ede31264a5f0f2461
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for aaf 0.3.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page