-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
80 lines (65 loc) · 2.11 KB
/
__init__.py
File metadata and controls
80 lines (65 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
"""Agent Runner - Production-ready orchestration for OpenAI Agents.
This library provides:
- Background worker pool with Redis-backed task queue
- Activity tracking with pluggable storage backends
- OpenAI Agents SDK runner with max turns recovery
- Type-safe task context via Pydantic models
Example:
from uuid import UUID
from pydantic import BaseModel
import agentexec as ax
# Create worker pool
engine = create_engine("sqlite:///agents.db")
pool = ax.WorkerPool(engine=engine)
# Define typed context for your task
class ResearchContext(BaseModel):
company_name: str
# Register task with pool
@pool.task("research_company")
async def research_company(agent_id: UUID, context: ResearchContext):
print(f"Researching {context.company_name}") # Typed!
# Enqueue from anywhere (e.g., web handler)
task = ax.enqueue("research_company", ResearchContext(company_name="Acme"))
# Start worker pool
pool.start()
"""
from importlib.metadata import PackageNotFoundError, version
from agentexec.config import CONF
from agentexec.core.db import Base
from agentexec.core.queue import Priority, enqueue
from agentexec.core.results import gather, get_result
from agentexec.core.task import Task, TaskDefinition, TaskHandler, TaskHandlerKwargs
from agentexec.worker import WorkerPool
from agentexec.pipeline import Pipeline
from agentexec.runners import BaseAgentRunner
try:
__version__ = version("agent-runner")
except PackageNotFoundError:
__version__ = "0.0.0.dev"
__all__ = [
"CONF",
"Base",
"Pipeline",
"WorkerPool",
"Task",
"TaskDefinition",
"TaskHandler",
"TaskHandlerKwargs",
"Priority",
"enqueue",
"gather",
"get_result",
"BaseAgentRunner",
]
# OpenAI runner is only available if agents package is installed
try:
from agentexec.runners import OpenAIRunner
__all__.append("OpenAIRunner")
except ImportError:
pass
# Google ADK runner is only available if google-adk package is installed
try:
from agentexec.runners import GoogleADKRunner
__all__.append("GoogleADKRunner")
except ImportError:
pass