Skip to main content

AAF (Agentic AI Framework)

Project description

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.

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

aaf-0.3.9.tar.gz (97.4 kB view details)

Uploaded Source

Built Distribution

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

aaf-0.3.9-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file aaf-0.3.9.tar.gz.

File metadata

  • Download URL: aaf-0.3.9.tar.gz
  • Upload date:
  • Size: 97.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for aaf-0.3.9.tar.gz
Algorithm Hash digest
SHA256 be2a1c5cfcc78a37d16f8c70be98a3e75c29a600149fc2da6db5a7e0c76d275c
MD5 90d1e4fb8463a90ad9adf575f37ee482
BLAKE2b-256 460dbf5c69916a4f5a652eca3d92a7ff92443430d57e4fb097fdf1ee54e73eec

See more details on using hashes here.

File details

Details for the file aaf-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: aaf-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for aaf-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fdbf73cded7c8e89b37e71e5c9c287da15a6c1b50f8381d90bfca43abcaf8332
MD5 cf49c3e71837755fd488c6e566e4015d
BLAKE2b-256 04deb5eef99dc6b174b61cef1f623787b3c98969acaf81284bd5af72371fb5ac

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