CodeAct-style AI agent framework for Python
Project description
dragen
CodeAct-style AI agent framework for Python.
Installation
pip install dragen
Quick Start
from dragen import Agent
# Create an agent
agent = Agent("gpt-4o")
# Register a tool
def search(args):
query = args[0]
return {"results": [f"Found: {query}"]}
agent.register_function("search", search)
# Run a task
result = agent.run("Search for Python tutorials")
print(result)
Features
- CodeAct pattern: LLM writes Python code to accomplish tasks
- Secure sandbox: Code runs in a sandboxed environment
- Tool registration: Expose Python functions as tools for the agent
- Multi-agent support: Share data between agents via Context
Configuration
from dragen import Agent
agent = Agent(
"gpt-4o",
max_iterations=10,
temperature=0.7,
max_tokens=4096,
system="You are a helpful assistant"
)
Tool Registration
Simple function
def add(args):
return args[0] + args[1]
agent.register_function("add", add)
With type information
from dragen import ToolInfo
info = ToolInfo("search", "Search the web") \
.arg_required("query", "str", "The search query") \
.returns("dict")
def search(args):
query = args[0]
return {"results": ["result1", "result2"]}
agent.register_tool(info, search)
Multi-Agent with Context
from dragen import Agent, Context
ctx = Context()
# Planner writes output to context
planner = Agent("gpt-4o")
planner.to_context(ctx, "plan")
planner.run("Create a research plan about AI")
# Executor reads from context
executor = Agent("gpt-4o")
executor.from_context(ctx, "plan")
executor.run("Execute the research plan")
Environment Variables
Set your API key based on the model provider:
OPENAI_API_KEYfor OpenAI models (gpt-4o, etc.)ANTHROPIC_API_KEYfor Anthropic models (claude-*, etc.)GROQ_API_KEYfor Groq models
License
Apache-2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
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 dragen-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: dragen-0.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87749bd41cadd59e588044c1a000f2d884a37667147d8a51fd9e53921a16b575
|
|
| MD5 |
8331dd14b9d27fb367f7704b131e231c
|
|
| BLAKE2b-256 |
797d66955f29b28c771b7984764967a889b5d19791411e522b6856a63c90234f
|
File details
Details for the file dragen-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: dragen-0.2.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 7.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
007a30f5914886adac2a07c7186d87c12f50a39b3f15af452a3b7e2963ac350f
|
|
| MD5 |
4178c8b6eca6ef05de1f0da4415334ea
|
|
| BLAKE2b-256 |
6e7880275938ff835da032fba23d0d5d89f152a3f56f3c05e524f377052c1346
|
File details
Details for the file dragen-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: dragen-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.4 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4017c004c313bd15af76d917b5bc640a70531c7869694e833efbe506bcf8d45b
|
|
| MD5 |
958c746e12cc3e373c73279ef57c25e8
|
|
| BLAKE2b-256 |
0900fa9eba7ba361af819c94c401f35c943fe4ec9cb4ea4922c1f828234b6455
|