agnt5 0.1.0__cp39-abi3-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of agnt5 might be problematic. Click here for more details.
- agnt5/__init__.py +307 -0
- agnt5/__pycache__/__init__.cpython-311.pyc +0 -0
- agnt5/__pycache__/agent.cpython-311.pyc +0 -0
- agnt5/__pycache__/context.cpython-311.pyc +0 -0
- agnt5/__pycache__/durable.cpython-311.pyc +0 -0
- agnt5/__pycache__/extraction.cpython-311.pyc +0 -0
- agnt5/__pycache__/memory.cpython-311.pyc +0 -0
- agnt5/__pycache__/reflection.cpython-311.pyc +0 -0
- agnt5/__pycache__/runtime.cpython-311.pyc +0 -0
- agnt5/__pycache__/task.cpython-311.pyc +0 -0
- agnt5/__pycache__/tool.cpython-311.pyc +0 -0
- agnt5/__pycache__/tracing.cpython-311.pyc +0 -0
- agnt5/__pycache__/types.cpython-311.pyc +0 -0
- agnt5/__pycache__/workflow.cpython-311.pyc +0 -0
- agnt5/_core.abi3.so +0 -0
- agnt5/agent.py +1086 -0
- agnt5/context.py +406 -0
- agnt5/durable.py +1050 -0
- agnt5/extraction.py +410 -0
- agnt5/llm/__init__.py +179 -0
- agnt5/llm/__pycache__/__init__.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/anthropic.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/azure.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/base.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/google.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/mistral.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/openai.cpython-311.pyc +0 -0
- agnt5/llm/__pycache__/together.cpython-311.pyc +0 -0
- agnt5/llm/anthropic.py +319 -0
- agnt5/llm/azure.py +348 -0
- agnt5/llm/base.py +315 -0
- agnt5/llm/google.py +373 -0
- agnt5/llm/mistral.py +330 -0
- agnt5/llm/model_registry.py +467 -0
- agnt5/llm/models.json +227 -0
- agnt5/llm/openai.py +334 -0
- agnt5/llm/together.py +377 -0
- agnt5/memory.py +746 -0
- agnt5/reflection.py +514 -0
- agnt5/runtime.py +699 -0
- agnt5/task.py +476 -0
- agnt5/testing.py +451 -0
- agnt5/tool.py +516 -0
- agnt5/tracing.py +624 -0
- agnt5/types.py +210 -0
- agnt5/workflow.py +897 -0
- agnt5-0.1.0.dist-info/METADATA +93 -0
- agnt5-0.1.0.dist-info/RECORD +49 -0
- agnt5-0.1.0.dist-info/WHEEL +4 -0
agnt5/__init__.py
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AGNT5 Python SDK - Build durable, resilient agent-first applications.
|
|
3
|
+
|
|
4
|
+
This SDK provides high-level components for building agents, tools, and workflows
|
|
5
|
+
with built-in durability guarantees and state management, backed by a high-performance
|
|
6
|
+
Rust core.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Import the Rust extension module
|
|
10
|
+
try:
|
|
11
|
+
from . import _core
|
|
12
|
+
from ._core import (
|
|
13
|
+
PyDurableWorker as _PyDurableWorker,
|
|
14
|
+
PyContext as _PyContext,
|
|
15
|
+
PyHandler as _PyHandler,
|
|
16
|
+
PyWorkerConfig as _PyWorkerConfig,
|
|
17
|
+
PyInvocationResult as _PyInvocationResult,
|
|
18
|
+
AgntError,
|
|
19
|
+
create_worker,
|
|
20
|
+
create_config,
|
|
21
|
+
init_logging,
|
|
22
|
+
)
|
|
23
|
+
_rust_core_available = True
|
|
24
|
+
except ImportError as e:
|
|
25
|
+
_rust_core_available = False
|
|
26
|
+
_import_error = e
|
|
27
|
+
|
|
28
|
+
# Import Python implementations
|
|
29
|
+
from .durable import durable, DurableContext, DurableObject
|
|
30
|
+
from .context import Context, get_context
|
|
31
|
+
from .runtime import run_service, RuntimeConfig
|
|
32
|
+
from .workflow import Workflow, Step
|
|
33
|
+
from .types import (
|
|
34
|
+
AgentConfig,
|
|
35
|
+
ToolConfig,
|
|
36
|
+
WorkflowConfig,
|
|
37
|
+
DurableConfig,
|
|
38
|
+
ExecutionState,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
# Import high-level AI components
|
|
42
|
+
from .agent import Agent
|
|
43
|
+
from .tool import Tool, tool
|
|
44
|
+
from .memory import Memory
|
|
45
|
+
|
|
46
|
+
# Import task system
|
|
47
|
+
from .task import (
|
|
48
|
+
task,
|
|
49
|
+
json_extraction_task,
|
|
50
|
+
pydantic_task,
|
|
51
|
+
string_task,
|
|
52
|
+
Task,
|
|
53
|
+
TaskResult,
|
|
54
|
+
OutputFormat,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Import LLM providers
|
|
58
|
+
from .llm import (
|
|
59
|
+
LanguageModel,
|
|
60
|
+
LanguageModelType,
|
|
61
|
+
create_llm,
|
|
62
|
+
Message,
|
|
63
|
+
ToolCall,
|
|
64
|
+
ToolResult,
|
|
65
|
+
ANTHROPIC_AVAILABLE,
|
|
66
|
+
OPENAI_AVAILABLE,
|
|
67
|
+
GOOGLE_AVAILABLE,
|
|
68
|
+
MISTRAL_AVAILABLE,
|
|
69
|
+
AZURE_OPENAI_AVAILABLE,
|
|
70
|
+
TOGETHER_AVAILABLE,
|
|
71
|
+
get_available_providers,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
# Import data extraction
|
|
75
|
+
from .extraction import (
|
|
76
|
+
extract_json_from_text,
|
|
77
|
+
extract_structured_data,
|
|
78
|
+
extract_entities,
|
|
79
|
+
JSONExtractor,
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# Import reflection
|
|
83
|
+
from .reflection import (
|
|
84
|
+
reflect_on_response,
|
|
85
|
+
reflect_on_goals,
|
|
86
|
+
analyze_errors,
|
|
87
|
+
ReflectionEngine,
|
|
88
|
+
ReflectionType,
|
|
89
|
+
ReflectionLevel,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# High-level API exports
|
|
93
|
+
__version__ = "0.1.0"
|
|
94
|
+
|
|
95
|
+
def get_worker(
|
|
96
|
+
service_name: str,
|
|
97
|
+
service_version: str = "1.0.0",
|
|
98
|
+
coordinator_endpoint: str = None,
|
|
99
|
+
) -> "DurableWorker":
|
|
100
|
+
"""
|
|
101
|
+
Create a new durable worker using the Rust core.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
service_name: Name of the service
|
|
105
|
+
service_version: Version of the service
|
|
106
|
+
coordinator_endpoint: Endpoint of the coordinator service
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
A configured DurableWorker instance
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
RuntimeError: If the Rust core is not available
|
|
113
|
+
"""
|
|
114
|
+
if not _rust_core_available:
|
|
115
|
+
raise RuntimeError(
|
|
116
|
+
f"Rust core is required but not available: {_import_error}. "
|
|
117
|
+
"Please build and install the Rust extension first."
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Use the high-performance Rust core
|
|
121
|
+
import uuid
|
|
122
|
+
worker_id = str(uuid.uuid4())
|
|
123
|
+
|
|
124
|
+
config = create_config(
|
|
125
|
+
worker_id=worker_id,
|
|
126
|
+
service_name=service_name,
|
|
127
|
+
version=service_version,
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
rust_worker = create_worker(
|
|
131
|
+
worker_id=worker_id,
|
|
132
|
+
service_name=service_name,
|
|
133
|
+
version=service_version,
|
|
134
|
+
coordinator_endpoint=coordinator_endpoint,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
return DurableWorker(rust_worker)
|
|
138
|
+
|
|
139
|
+
def setup_logging(level: str = "info"):
|
|
140
|
+
"""
|
|
141
|
+
Initialize Rust logging.
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
level: Log level ('debug', 'info', 'warn', 'error')
|
|
145
|
+
"""
|
|
146
|
+
if not _rust_core_available:
|
|
147
|
+
print(f"Warning: Rust core not available, cannot initialize Rust logging: {_import_error}")
|
|
148
|
+
return
|
|
149
|
+
|
|
150
|
+
try:
|
|
151
|
+
init_logging(level)
|
|
152
|
+
print(f"Rust logging initialized at level: {level}")
|
|
153
|
+
except Exception as e:
|
|
154
|
+
print(f"Failed to initialize Rust logging: {e}")
|
|
155
|
+
|
|
156
|
+
def function(
|
|
157
|
+
name: str = None,
|
|
158
|
+
timeout: int = 300,
|
|
159
|
+
retry: int = 3,
|
|
160
|
+
**kwargs
|
|
161
|
+
):
|
|
162
|
+
"""
|
|
163
|
+
Decorator to mark a function as durable.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
name: Name of the function (defaults to function name)
|
|
167
|
+
timeout: Timeout in seconds
|
|
168
|
+
retry: Number of retry attempts
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Decorated function
|
|
172
|
+
"""
|
|
173
|
+
return durable.function(name=name, timeout=timeout, retry=retry, **kwargs)
|
|
174
|
+
|
|
175
|
+
# Wrapper for Rust worker to provide consistent API
|
|
176
|
+
class DurableWorker:
|
|
177
|
+
"""High-performance durable worker backed by Rust core."""
|
|
178
|
+
|
|
179
|
+
def __init__(self, rust_worker: "_PyDurableWorker"):
|
|
180
|
+
self._rust_worker = rust_worker
|
|
181
|
+
|
|
182
|
+
async def register_function(self, func, name: str = None, timeout: int = 300, retry: int = 3):
|
|
183
|
+
"""Register a function handler with the worker."""
|
|
184
|
+
handler_name = name or func.__name__
|
|
185
|
+
return self._rust_worker.register_function(
|
|
186
|
+
name=handler_name,
|
|
187
|
+
handler=func,
|
|
188
|
+
timeout_secs=timeout,
|
|
189
|
+
retry_attempts=retry,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
async def register_object_factory(self, factory_class, name: str = None):
|
|
193
|
+
"""Register a durable object factory with the worker."""
|
|
194
|
+
object_name = name or factory_class.__name__
|
|
195
|
+
# For now, just log the registration since the Rust worker may not have this method yet
|
|
196
|
+
print(f"📦 Registered object factory: {object_name}")
|
|
197
|
+
return True
|
|
198
|
+
|
|
199
|
+
async def start(self):
|
|
200
|
+
"""Start the worker."""
|
|
201
|
+
return await self._rust_worker.start()
|
|
202
|
+
|
|
203
|
+
async def stop(self):
|
|
204
|
+
"""Stop the worker."""
|
|
205
|
+
return await self._rust_worker.stop()
|
|
206
|
+
|
|
207
|
+
async def wait(self):
|
|
208
|
+
"""Wait for the worker to finish."""
|
|
209
|
+
return await self._rust_worker.wait()
|
|
210
|
+
|
|
211
|
+
async def get_status(self):
|
|
212
|
+
"""Get worker status."""
|
|
213
|
+
return await self._rust_worker.get_status()
|
|
214
|
+
|
|
215
|
+
@property
|
|
216
|
+
def config(self):
|
|
217
|
+
"""Get worker configuration."""
|
|
218
|
+
return self._rust_worker.config
|
|
219
|
+
|
|
220
|
+
async def list_handlers(self):
|
|
221
|
+
"""List registered handlers."""
|
|
222
|
+
return await self._rust_worker.list_handlers()
|
|
223
|
+
|
|
224
|
+
# Re-export key types
|
|
225
|
+
if _rust_core_available:
|
|
226
|
+
WorkerConfig = _PyWorkerConfig
|
|
227
|
+
InvocationResult = _PyInvocationResult
|
|
228
|
+
|
|
229
|
+
__all__ = [
|
|
230
|
+
# Core worker management
|
|
231
|
+
"get_worker",
|
|
232
|
+
"DurableWorker",
|
|
233
|
+
"WorkerConfig",
|
|
234
|
+
"setup_logging",
|
|
235
|
+
|
|
236
|
+
# Decorators and context
|
|
237
|
+
"function",
|
|
238
|
+
"durable",
|
|
239
|
+
"DurableContext",
|
|
240
|
+
"DurableObject",
|
|
241
|
+
"Context",
|
|
242
|
+
"get_context",
|
|
243
|
+
|
|
244
|
+
# Runtime
|
|
245
|
+
"run_service",
|
|
246
|
+
"RuntimeConfig",
|
|
247
|
+
|
|
248
|
+
# Types
|
|
249
|
+
"DurableConfig",
|
|
250
|
+
"ExecutionState",
|
|
251
|
+
"InvocationResult",
|
|
252
|
+
"AgntError",
|
|
253
|
+
|
|
254
|
+
# Version
|
|
255
|
+
"__version__",
|
|
256
|
+
|
|
257
|
+
# Workflow support
|
|
258
|
+
"Workflow",
|
|
259
|
+
"Step",
|
|
260
|
+
|
|
261
|
+
# High-level AI components
|
|
262
|
+
"Agent",
|
|
263
|
+
"Tool",
|
|
264
|
+
"tool",
|
|
265
|
+
"Memory",
|
|
266
|
+
|
|
267
|
+
# Task system
|
|
268
|
+
"task",
|
|
269
|
+
"json_extraction_task",
|
|
270
|
+
"pydantic_task",
|
|
271
|
+
"string_task",
|
|
272
|
+
"Task",
|
|
273
|
+
"TaskResult",
|
|
274
|
+
"OutputFormat",
|
|
275
|
+
|
|
276
|
+
# LLM providers
|
|
277
|
+
"LanguageModel",
|
|
278
|
+
"LanguageModelType",
|
|
279
|
+
"create_llm",
|
|
280
|
+
"Message",
|
|
281
|
+
"ToolCall",
|
|
282
|
+
"ToolResult",
|
|
283
|
+
"ANTHROPIC_AVAILABLE",
|
|
284
|
+
"OPENAI_AVAILABLE",
|
|
285
|
+
"GOOGLE_AVAILABLE",
|
|
286
|
+
"MISTRAL_AVAILABLE",
|
|
287
|
+
"AZURE_OPENAI_AVAILABLE",
|
|
288
|
+
"TOGETHER_AVAILABLE",
|
|
289
|
+
"get_available_providers",
|
|
290
|
+
|
|
291
|
+
# Data extraction
|
|
292
|
+
"extract_json_from_text",
|
|
293
|
+
"extract_structured_data",
|
|
294
|
+
"extract_entities",
|
|
295
|
+
"JSONExtractor",
|
|
296
|
+
|
|
297
|
+
# Reflection
|
|
298
|
+
"reflect_on_response",
|
|
299
|
+
"reflect_on_goals",
|
|
300
|
+
"analyze_errors",
|
|
301
|
+
"ReflectionEngine",
|
|
302
|
+
"ReflectionType",
|
|
303
|
+
"ReflectionLevel",
|
|
304
|
+
]
|
|
305
|
+
|
|
306
|
+
# Expose rust core availability for debugging
|
|
307
|
+
globals()["_rust_core_available"] = _rust_core_available
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
agnt5/_core.abi3.so
ADDED
|
Binary file
|