A lightweight Python AI agent framework
Project description
Axi-EasyAgent
A lightweight Python AI agent framework with conversation management, tool calling, and memory persistence capabilities.
How lightweight is it?
Why Axi-EasyAgent?
Do you know how much space a typical AI library takes nowadays? Up to 200MB! That's larger than a web browser!
If you only want AI to call your functions, how much of that 200MB do you actually need? The answer is right here.
Features
- 🤖 Smart Conversations: Streaming conversation support based on OpenAI-compatible APIs
- 🔧 Tool Calling: Automatically convert Python functions into AI-callable tools
- 💾 Memory Management: Built-in conversation memory system with persistent storage and auto-compression
- ⚡ Async Processing: Full async programming support for improved response efficiency
- 🔄 Streaming Output: Real-time streaming responses for enhanced user experience
Installation
pip install axi-easyagent
Quick Start
1. Environment Configuration
Configure environment variables, or hardcode them directly in your code (not recommended)
OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1
OPENAI_API_KEY=your-api-key-here
Note: easyagent does not automatically read .env files. Please load them yourself.
2. Quick Start Example
import asyncio
from typing import Annotated
from easyagent import Agent
async def get_weather(city: str) -> str:
"""Get weather information"""
return f"The weather in {city} is sunny"
def get_weather_detail(city: Annotated[str, "Can be precise to district, e.g.: Shanghai/Qingpu District"]) -> str:
"""Get detailed weather information"""
return f"Detailed weather info for {city}: Temperature 25°C, Humidity 60%"
async def main():
agent = Agent(
"deepseek-v4-flash",
tools=[get_weather, get_weather_detail],
prompt="Keep responses brief"
)
while (msg := input("You: ")) != "q":
async for output in agent.chat(msg):
print(output, end="")
print()
if __name__ == "__main__":
asyncio.run(main())
3. Memory Persistence
import os
from easyagent import Agent, Memory
# Load existing memory or create new memory
if os.path.exists("./memory.json"):
memory = Memory.load("./memory.json")
else:
memory = Memory()
memory.add_message("Hello!") # role: user
memory.add_message("You're bad!") # role: assistant
agent = Agent("deepseek-v4-flash", memory=memory)
# Save memory after conversation
memory.save("./memory.json")
Core Components
Agent Class
The core agent class responsible for managing conversations, tool calls, and memory.
Parameters:
model(str): Model namebase_url(str, optional): API base URLapi_key(str, optional): API keymemory(Memory, optional): Memory instanceprompt(str, optional): System prompttools(list[Callable], optional): Available tools listcomplete_memory(bool): Whether to save tool call and thinking processes to memorymax_tool_call(int): Maximum tool call limit
Memory Class
Conversation memory management class that inherits from list, supporting message CRUD operations and persistence. If you want to customize memory management, you can inherit from the Memory class and implement relevant methods.
Main Methods:
add_user_message(message): Add user messageadd_assistant_message(message): Add assistant messageload(json_file): Load memory from JSON filesave(json_file): Save memory to JSON filecompress(): Compress memory by removing reasoning content and tool call records
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
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 axi_easyagent-0.1.0.tar.gz.
File metadata
- Download URL: axi_easyagent-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5be3e9a1ad10fb9d92f461545eff48455b03e4831358a6ed7513dea18ee2831b
|
|
| MD5 |
580d57946070e7f00ed180526819c37a
|
|
| BLAKE2b-256 |
d0c03fba80b0275065fc66d9e78bd09c8790a7fbb9722a0b96465ea29d435d87
|
File details
Details for the file axi_easyagent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: axi_easyagent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a84f37856979e51eef253c8bc7826923e82ce25ef02f7fa88a0caef8d4c83c6c
|
|
| MD5 |
c51f94f30c5e58a93cadf8bb5001ea12
|
|
| BLAKE2b-256 |
502d67abff19271f26edbbfe9f5466877c69b33278c1dfd37d6ec56419ffcc62
|