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.
- 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/types.py
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Type definitions for the AGNT5 SDK.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, List, Optional, Union, Callable, TypeVar, Generic
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from dataclasses import dataclass, field
|
|
8
|
+
from datetime import datetime, timezone
|
|
9
|
+
import uuid
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExecutionState(Enum):
|
|
13
|
+
"""State of a durable execution."""
|
|
14
|
+
PENDING = "pending"
|
|
15
|
+
RUNNING = "running"
|
|
16
|
+
SUSPENDED = "suspended"
|
|
17
|
+
COMPLETED = "completed"
|
|
18
|
+
FAILED = "failed"
|
|
19
|
+
CANCELLED = "cancelled"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MessageRole(Enum):
|
|
23
|
+
"""Role of a message in a conversation."""
|
|
24
|
+
SYSTEM = "system"
|
|
25
|
+
USER = "user"
|
|
26
|
+
ASSISTANT = "assistant"
|
|
27
|
+
TOOL = "tool"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class Message:
|
|
32
|
+
"""Represents a message in an agent conversation."""
|
|
33
|
+
role: MessageRole
|
|
34
|
+
content: str
|
|
35
|
+
name: Optional[str] = None
|
|
36
|
+
tool_calls: Optional[List["ToolCall"]] = None
|
|
37
|
+
tool_call_id: Optional[str] = None
|
|
38
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
39
|
+
timestamp: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass
|
|
43
|
+
class ToolCall:
|
|
44
|
+
"""Represents a tool invocation."""
|
|
45
|
+
id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
46
|
+
name: str = ""
|
|
47
|
+
arguments: Dict[str, Any] = field(default_factory=dict)
|
|
48
|
+
|
|
49
|
+
def __post_init__(self):
|
|
50
|
+
if not self.id:
|
|
51
|
+
self.id = str(uuid.uuid4())
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@dataclass
|
|
55
|
+
class ToolResult:
|
|
56
|
+
"""Result from a tool execution."""
|
|
57
|
+
tool_call_id: str
|
|
58
|
+
output: Any
|
|
59
|
+
error: Optional[str] = None
|
|
60
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@dataclass
|
|
64
|
+
class AgentConfig:
|
|
65
|
+
"""Configuration for an Agent."""
|
|
66
|
+
name: str
|
|
67
|
+
description: Optional[str] = None
|
|
68
|
+
model: str = "gpt-4"
|
|
69
|
+
temperature: float = 0.7
|
|
70
|
+
max_tokens: Optional[int] = None
|
|
71
|
+
tools: List[Union["Tool", Callable]] = field(default_factory=list)
|
|
72
|
+
system_prompt: Optional[str] = None
|
|
73
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
74
|
+
|
|
75
|
+
# Durability settings
|
|
76
|
+
enable_durability: bool = True
|
|
77
|
+
checkpoint_interval: int = 10 # Checkpoint every N messages
|
|
78
|
+
max_retries: int = 3
|
|
79
|
+
retry_delay: float = 1.0
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@dataclass
|
|
83
|
+
class ToolConfig:
|
|
84
|
+
"""Configuration for a Tool."""
|
|
85
|
+
name: str
|
|
86
|
+
description: str
|
|
87
|
+
parameters: Dict[str, Any] = field(default_factory=dict)
|
|
88
|
+
returns: Optional[Dict[str, Any]] = None
|
|
89
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
90
|
+
|
|
91
|
+
# Execution settings
|
|
92
|
+
timeout: Optional[float] = None
|
|
93
|
+
max_retries: int = 3
|
|
94
|
+
retry_delay: float = 1.0
|
|
95
|
+
enable_durability: bool = True
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@dataclass
|
|
99
|
+
class WorkflowConfig:
|
|
100
|
+
"""Configuration for a Workflow."""
|
|
101
|
+
name: str
|
|
102
|
+
description: Optional[str] = None
|
|
103
|
+
version: str = "1.0.0"
|
|
104
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
105
|
+
|
|
106
|
+
# Durability settings
|
|
107
|
+
enable_durability: bool = True
|
|
108
|
+
checkpoint_on_step: bool = True
|
|
109
|
+
max_parallel_steps: int = 10
|
|
110
|
+
timeout: Optional[float] = None
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class DurableConfig:
|
|
115
|
+
"""Configuration for durable functions and objects."""
|
|
116
|
+
name: str
|
|
117
|
+
version: str = "1.0.0"
|
|
118
|
+
|
|
119
|
+
# Execution settings
|
|
120
|
+
deterministic: bool = True
|
|
121
|
+
idempotent: bool = True
|
|
122
|
+
max_retries: int = 3
|
|
123
|
+
retry_delay: float = 1.0
|
|
124
|
+
timeout: Optional[float] = None
|
|
125
|
+
|
|
126
|
+
# State management
|
|
127
|
+
checkpoint_interval: Optional[int] = None
|
|
128
|
+
state_retention_days: int = 30
|
|
129
|
+
|
|
130
|
+
# Concurrency
|
|
131
|
+
max_concurrent_executions: Optional[int] = None
|
|
132
|
+
rate_limit: Optional[int] = None # Per second
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@dataclass
|
|
136
|
+
class ExecutionContext:
|
|
137
|
+
"""Context for a durable execution."""
|
|
138
|
+
execution_id: str
|
|
139
|
+
workflow_id: Optional[str] = None
|
|
140
|
+
parent_execution_id: Optional[str] = None
|
|
141
|
+
state: ExecutionState = ExecutionState.PENDING
|
|
142
|
+
started_at: Optional[datetime] = None
|
|
143
|
+
completed_at: Optional[datetime] = None
|
|
144
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
145
|
+
|
|
146
|
+
# Retry information
|
|
147
|
+
attempt: int = 1
|
|
148
|
+
last_error: Optional[str] = None
|
|
149
|
+
|
|
150
|
+
# Checkpoint data
|
|
151
|
+
last_checkpoint: Optional[datetime] = None
|
|
152
|
+
checkpoint_data: Optional[Dict[str, Any]] = None
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
T = TypeVar('T')
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class DurablePromise(Generic[T]):
|
|
159
|
+
"""A promise for durable async operations."""
|
|
160
|
+
def __init__(self, execution_id: str, result_type: type[T]):
|
|
161
|
+
self.execution_id = execution_id
|
|
162
|
+
self.result_type = result_type
|
|
163
|
+
self._result: Optional[T] = None
|
|
164
|
+
self._error: Optional[Exception] = None
|
|
165
|
+
self._completed = False
|
|
166
|
+
|
|
167
|
+
@property
|
|
168
|
+
def is_completed(self) -> bool:
|
|
169
|
+
return self._completed
|
|
170
|
+
|
|
171
|
+
def get(self, timeout: Optional[float] = None) -> T:
|
|
172
|
+
"""Get the result, blocking if necessary."""
|
|
173
|
+
if self._error:
|
|
174
|
+
raise self._error
|
|
175
|
+
if not self._completed:
|
|
176
|
+
raise RuntimeError("Promise not yet resolved")
|
|
177
|
+
return self._result
|
|
178
|
+
|
|
179
|
+
async def wait(self, timeout: Optional[float] = None) -> T:
|
|
180
|
+
"""Async wait for the result."""
|
|
181
|
+
# Implementation would integrate with the runtime
|
|
182
|
+
return self.get(timeout)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@dataclass
|
|
186
|
+
class MemoryEntry:
|
|
187
|
+
"""An entry in agent memory."""
|
|
188
|
+
content: Any
|
|
189
|
+
id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
190
|
+
embedding: Optional[List[float]] = None
|
|
191
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
192
|
+
created_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
193
|
+
accessed_at: datetime = field(default_factory=lambda: datetime.now(timezone.utc))
|
|
194
|
+
access_count: int = 0
|
|
195
|
+
|
|
196
|
+
def access(self):
|
|
197
|
+
"""Mark this entry as accessed."""
|
|
198
|
+
self.accessed_at = datetime.now(timezone.utc)
|
|
199
|
+
self.access_count += 1
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@dataclass
|
|
203
|
+
class MemoryQuery:
|
|
204
|
+
"""Query for searching memory."""
|
|
205
|
+
query: Optional[str] = None
|
|
206
|
+
embedding: Optional[List[float]] = None
|
|
207
|
+
filters: Dict[str, Any] = field(default_factory=dict)
|
|
208
|
+
limit: int = 10
|
|
209
|
+
include_metadata: bool = True
|
|
210
|
+
similarity_threshold: float = 0.7
|