A simple AI agent framework for Python
Project description
Vizra - Simple AI Agent Framework for Python
A lightweight, class-based AI agent framework for Python that uses litellm for LLM integration.
Installation
pip install vizra
Quick Start
Define an Agent
from vizra import BaseAgent
class CustomerSupportAgent(BaseAgent):
name = 'customer_support'
description = 'Helps customers with their inquiries'
instructions = 'You are a friendly customer support assistant.'
model = 'gpt-4o'
tools = [OrderLookupTool, RefundProcessorTool]
# Or load instructions from a file
class AdvancedSupportAgent(BaseAgent):
name = 'advanced_support'
description = 'Advanced support agent with complex instructions'
instructions_file = 'prompts/advanced_support.md' # Path relative to your project
model = 'gpt-4o'
tools = [OrderLookupTool, RefundProcessorTool]
Run the Agent
from my_agents import CustomerSupportAgent # Import your agent
# Simple usage
response = CustomerSupportAgent.run('How do I reset my password?')
# With context for conversation continuity
from vizra import AgentContext
context = AgentContext()
agent_runner = CustomerSupportAgent.with_context(context)
response1 = agent_runner.run("Hi, I need help")
response2 = agent_runner.run("Can you check my order?")
Define Tools
from vizra import ToolInterface, AgentContext
import json
class OrderLookupTool(ToolInterface):
def definition(self) -> dict:
return {
'name': 'order_lookup',
'description': 'Look up order information by order ID',
'parameters': {
'type': 'object',
'properties': {
'order_id': {
'type': 'string',
'description': 'The order ID to look up',
},
},
'required': ['order_id'],
},
}
def execute(self, arguments: dict, context: AgentContext) -> str:
order_id = arguments['order_id']
# Your implementation here
return json.dumps({"order_id": order_id, "status": "shipped"})
Features
- Class-based agent definition
- Tool integration with automatic execution loop (max 3 iterations)
- Context management for conversation history
- Support for multiple LLM providers via litellm
- Hook methods for monitoring and customization
- File-based instruction loading
- Simple and intuitive API
Hooks
Agents can override hook methods to add custom behavior:
class MonitoredAgent(BaseAgent):
def before_llm_call(self, messages, tools):
print(f"Making LLM call with {len(messages)} messages")
def after_llm_response(self, response, messages):
print(f"Response received with {response.usage.total_tokens} tokens")
def before_tool_call(self, tool_name, arguments, context):
print(f"Calling tool: {tool_name}")
def after_tool_result(self, tool_name, result, context):
print(f"Tool {tool_name} returned: {result}")
License
MIT
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
vizra-0.1.0.tar.gz
(15.2 kB
view details)
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
vizra-0.1.0-py3-none-any.whl
(7.3 kB
view details)
File details
Details for the file vizra-0.1.0.tar.gz.
File metadata
- Download URL: vizra-0.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93c0eeeb1dd320726147ff397382a7bffcf582c86a27b69675596e0b60db8818
|
|
| MD5 |
8a4f1a702d910d5f09445ba3a028985f
|
|
| BLAKE2b-256 |
e56afb5a11f70c4a513e134ff81a82c176bbbdbd6b24dea8d097109ffa6e950a
|
File details
Details for the file vizra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vizra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dcad7c37405e24d52ccbeeb0503f65dfd713f814adf609daa992f64d219e49f
|
|
| MD5 |
f2ae1e61f4b51af88ebacf7c6239367f
|
|
| BLAKE2b-256 |
21c6b54168fa2d8cbee91f7dcffa4e24a022338e0e5d6811d1f7383d36fdb4d4
|