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) 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 directoryllms/: LLM provider implementationsvirtual_models/: Virtual model implementationstools/: Tool definitionsthreads.py: Thread and Session managementlogging.py: Custom logging implementationutils.py: Utility functions
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aaf-0.3.4.tar.gz.
File metadata
- Download URL: aaf-0.3.4.tar.gz
- Upload date:
- Size: 56.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5679aee121aa21fee5e6fb23100af012a1ea74bd048d9c9890eb1d7310d1de4d
|
|
| MD5 |
35682a8dceab3209cd4c47c272594507
|
|
| BLAKE2b-256 |
848662c36242e654ad21409b3e275a337554e374f9ebf557ea456ac4053444c6
|
File details
Details for the file aaf-0.3.4-py3-none-any.whl.
File metadata
- Download URL: aaf-0.3.4-py3-none-any.whl
- Upload date:
- Size: 36.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d4e003973f3d9b93537470c5f9d598a1778df896bca458ca918277f2ccd86aa
|
|
| MD5 |
0187390a599b28227c936c55bebb1a25
|
|
| BLAKE2b-256 |
be92f0f9aa8f0b4a2a58f31fa528dd6a2a425a4a7bce46d02ac417b97708ae28
|