sofias-sdk-lite 0.1.0__py3-none-any.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.
- sofias_sdk_lite/__init__.py +262 -0
- sofias_sdk_lite/agent/__init__.py +67 -0
- sofias_sdk_lite/agent/agent.py +899 -0
- sofias_sdk_lite/agent/agent_builder.py +1221 -0
- sofias_sdk_lite/agent/agent_config.py +87 -0
- sofias_sdk_lite/agent/execution_context.py +222 -0
- sofias_sdk_lite/agent/middleware.py +118 -0
- sofias_sdk_lite/agent/response_workflow.py +232 -0
- sofias_sdk_lite/agent/streaming.py +119 -0
- sofias_sdk_lite/config/__init__.py +63 -0
- sofias_sdk_lite/config/agent_settings.py +72 -0
- sofias_sdk_lite/config/defaults.py +78 -0
- sofias_sdk_lite/config/runtime_config.py +201 -0
- sofias_sdk_lite/config/sdk_config.py +105 -0
- sofias_sdk_lite/config/source.py +168 -0
- sofias_sdk_lite/contracts/__init__.py +48 -0
- sofias_sdk_lite/contracts/agent_contracts.py +174 -0
- sofias_sdk_lite/contracts/base_contracts.py +115 -0
- sofias_sdk_lite/contracts/node_contracts.py +177 -0
- sofias_sdk_lite/contracts/strict_contract.py +34 -0
- sofias_sdk_lite/errors/__init__.py +76 -0
- sofias_sdk_lite/errors/circuit_breaker.py +150 -0
- sofias_sdk_lite/errors/error_handler.py +413 -0
- sofias_sdk_lite/errors/exceptions.py +408 -0
- sofias_sdk_lite/llm/__init__.py +27 -0
- sofias_sdk_lite/llm/protocol.py +92 -0
- sofias_sdk_lite/llm/tokens.py +19 -0
- sofias_sdk_lite/llm/tools.py +36 -0
- sofias_sdk_lite/messaging/__init__.py +47 -0
- sofias_sdk_lite/messaging/models.py +516 -0
- sofias_sdk_lite/nodes/__init__.py +104 -0
- sofias_sdk_lite/nodes/aggregator_config.py +78 -0
- sofias_sdk_lite/nodes/aggregator_node.py +390 -0
- sofias_sdk_lite/nodes/base_node.py +211 -0
- sofias_sdk_lite/nodes/delegation_config.py +281 -0
- sofias_sdk_lite/nodes/delegation_node.py +1120 -0
- sofias_sdk_lite/nodes/delegation_transport.py +228 -0
- sofias_sdk_lite/nodes/function_node.py +289 -0
- sofias_sdk_lite/nodes/llm_node.py +1451 -0
- sofias_sdk_lite/nodes/llm_node_config.py +266 -0
- sofias_sdk_lite/nodes/plan_executor.py +434 -0
- sofias_sdk_lite/nodes/planner_node.py +206 -0
- sofias_sdk_lite/nodes/planning_models.py +137 -0
- sofias_sdk_lite/nodes/prompt_assembler.py +266 -0
- sofias_sdk_lite/observability/__init__.py +47 -0
- sofias_sdk_lite/observability/_log.py +43 -0
- sofias_sdk_lite/observability/events.py +438 -0
- sofias_sdk_lite/observability/tracing.py +619 -0
- sofias_sdk_lite/py.typed +0 -0
- sofias_sdk_lite/rabbitmq/__init__.py +33 -0
- sofias_sdk_lite/rabbitmq/client.py +105 -0
- sofias_sdk_lite/rabbitmq/config.py +33 -0
- sofias_sdk_lite/rabbitmq/consumer.py +149 -0
- sofias_sdk_lite/rabbitmq/delegation_transport.py +400 -0
- sofias_sdk_lite/rabbitmq/publisher.py +273 -0
- sofias_sdk_lite/rabbitmq/rpc_client.py +338 -0
- sofias_sdk_lite/rabbitmq/types.py +68 -0
- sofias_sdk_lite/routing/__init__.py +27 -0
- sofias_sdk_lite/routing/router.py +301 -0
- sofias_sdk_lite/routing/strategies.py +485 -0
- sofias_sdk_lite/runner/__init__.py +8 -0
- sofias_sdk_lite/runner/config.py +43 -0
- sofias_sdk_lite/runner/runner.py +243 -0
- sofias_sdk_lite/state/__init__.py +26 -0
- sofias_sdk_lite/state/conversation_state.py +259 -0
- sofias_sdk_lite/state/history.py +104 -0
- sofias_sdk_lite/state/memory.py +123 -0
- sofias_sdk_lite/tools.py +482 -0
- sofias_sdk_lite/workflows/__init__.py +28 -0
- sofias_sdk_lite/workflows/chat.py +113 -0
- sofias_sdk_lite/workflows/null.py +35 -0
- sofias_sdk_lite-0.1.0.dist-info/METADATA +151 -0
- sofias_sdk_lite-0.1.0.dist-info/RECORD +74 -0
- sofias_sdk_lite-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""Sofias Agents SDK — build agents on the Sofias agent graph and run them over RabbitMQ.
|
|
2
|
+
|
|
3
|
+
Quickstart::
|
|
4
|
+
|
|
5
|
+
from sofias_sdk_lite import AgentBuilder, InputContract, NodeContract, OutputContract
|
|
6
|
+
|
|
7
|
+
class GreetInput(InputContract):
|
|
8
|
+
name: str
|
|
9
|
+
|
|
10
|
+
class GreetOutput(OutputContract):
|
|
11
|
+
greeting: str
|
|
12
|
+
|
|
13
|
+
agent = (
|
|
14
|
+
AgentBuilder("hello_agent", version="0.1.0")
|
|
15
|
+
.with_settings_class(MySettings)
|
|
16
|
+
.with_contract(input_schema=GreetInput, output_schema=GreetOutput)
|
|
17
|
+
.add_function_node(
|
|
18
|
+
"greeter",
|
|
19
|
+
NodeContract(input_schema=GreetInput, output_schema=GreetOutput),
|
|
20
|
+
process_fn=lambda data, ctx: {"greeting": f"Hello, {data['name']}!"},
|
|
21
|
+
)
|
|
22
|
+
.set_entry_node("greeter")
|
|
23
|
+
.set_terminal("greeter")
|
|
24
|
+
.build()
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
See the docs site for the full guide: agent graph concepts, running an agent
|
|
28
|
+
against RabbitMQ, streaming, delegation, and testing.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
from __future__ import annotations
|
|
32
|
+
|
|
33
|
+
from sofias_sdk_lite.agent import (
|
|
34
|
+
Agent,
|
|
35
|
+
AgentBuildError,
|
|
36
|
+
AgentBuilder,
|
|
37
|
+
AgentConfig,
|
|
38
|
+
AgentLLMConfig,
|
|
39
|
+
AgentMiddleware,
|
|
40
|
+
BaseDelegationResponseWorkflow,
|
|
41
|
+
ExecutionContext,
|
|
42
|
+
LoggingMiddleware,
|
|
43
|
+
PublishFn,
|
|
44
|
+
ResponseWorkflow,
|
|
45
|
+
StreamingResponseWorkflow,
|
|
46
|
+
get_execution_context,
|
|
47
|
+
set_execution_context,
|
|
48
|
+
)
|
|
49
|
+
from sofias_sdk_lite.config import (
|
|
50
|
+
AgentSettings,
|
|
51
|
+
BaseAgentSettings,
|
|
52
|
+
ConfigSource,
|
|
53
|
+
EnvConfigSource,
|
|
54
|
+
RuntimeConfigError,
|
|
55
|
+
SDKConfig,
|
|
56
|
+
SettingsResolver,
|
|
57
|
+
StaticConfigSource,
|
|
58
|
+
)
|
|
59
|
+
from sofias_sdk_lite.contracts import (
|
|
60
|
+
AgentContract,
|
|
61
|
+
AgentMessage,
|
|
62
|
+
AgentResponse,
|
|
63
|
+
DelegationRequest,
|
|
64
|
+
DelegationResponse,
|
|
65
|
+
DelegationStatus,
|
|
66
|
+
InputContract,
|
|
67
|
+
NodeContract,
|
|
68
|
+
OutputContract,
|
|
69
|
+
ResponseStatus,
|
|
70
|
+
StrictContract,
|
|
71
|
+
)
|
|
72
|
+
from sofias_sdk_lite.errors import (
|
|
73
|
+
AgentSDKError,
|
|
74
|
+
CircuitBreakerConfig,
|
|
75
|
+
ConfigSourceError,
|
|
76
|
+
ContractValidationError,
|
|
77
|
+
ErrorHandler,
|
|
78
|
+
ErrorHandlerConfig,
|
|
79
|
+
GraphExecutionError,
|
|
80
|
+
InputValidationError,
|
|
81
|
+
NodeExecutionError,
|
|
82
|
+
OutputValidationError,
|
|
83
|
+
RetryPolicy,
|
|
84
|
+
RoutingError,
|
|
85
|
+
ToolExecutionError,
|
|
86
|
+
)
|
|
87
|
+
from sofias_sdk_lite.llm import (
|
|
88
|
+
LLMCallable,
|
|
89
|
+
LLMResponse,
|
|
90
|
+
StreamableLLMCallable,
|
|
91
|
+
TokenUsage,
|
|
92
|
+
ToolCall,
|
|
93
|
+
ToolSpec,
|
|
94
|
+
)
|
|
95
|
+
from sofias_sdk_lite.messaging import (
|
|
96
|
+
AgentTaskMessage,
|
|
97
|
+
ApiTaskMessage,
|
|
98
|
+
ChatRequest,
|
|
99
|
+
ChatResponse,
|
|
100
|
+
FileContent,
|
|
101
|
+
FileMessage,
|
|
102
|
+
StreamFragment,
|
|
103
|
+
)
|
|
104
|
+
from sofias_sdk_lite.nodes import (
|
|
105
|
+
AggregatorNode,
|
|
106
|
+
AggregatorNodeConfig,
|
|
107
|
+
BaseNode,
|
|
108
|
+
DelegationNode,
|
|
109
|
+
DelegationNodeConfig,
|
|
110
|
+
DelegationTransport,
|
|
111
|
+
FunctionNode,
|
|
112
|
+
LLMNode,
|
|
113
|
+
LLMNodeConfig,
|
|
114
|
+
NodeType,
|
|
115
|
+
NullDelegationTransport,
|
|
116
|
+
PlannerNode,
|
|
117
|
+
)
|
|
118
|
+
from sofias_sdk_lite.rabbitmq import (
|
|
119
|
+
AckPolicy,
|
|
120
|
+
RabbitMQClient,
|
|
121
|
+
RabbitMQConfig,
|
|
122
|
+
RabbitMQConsumer,
|
|
123
|
+
RabbitMQDelegationTransport,
|
|
124
|
+
RabbitMQPublisher,
|
|
125
|
+
RabbitMQRPCClient,
|
|
126
|
+
)
|
|
127
|
+
from sofias_sdk_lite.routing import (
|
|
128
|
+
CompositeStrategy,
|
|
129
|
+
ConditionalStrategy,
|
|
130
|
+
ConfidenceThresholdStrategy,
|
|
131
|
+
FanOutStrategy,
|
|
132
|
+
FieldPresenceStrategy,
|
|
133
|
+
FieldValueStrategy,
|
|
134
|
+
Router,
|
|
135
|
+
RoutingStrategy,
|
|
136
|
+
StaticRoute,
|
|
137
|
+
)
|
|
138
|
+
from sofias_sdk_lite.runner import AgentRunner, RunnerConfig
|
|
139
|
+
from sofias_sdk_lite.state import (
|
|
140
|
+
ConversationStateProvider,
|
|
141
|
+
HistoryProvider,
|
|
142
|
+
InMemoryHistory,
|
|
143
|
+
InMemoryStateProvider,
|
|
144
|
+
MemoryProvider,
|
|
145
|
+
Message,
|
|
146
|
+
)
|
|
147
|
+
from sofias_sdk_lite.workflows import ChatResponseWorkflow, NullWorkflow
|
|
148
|
+
|
|
149
|
+
__version__ = "0.1.0"
|
|
150
|
+
|
|
151
|
+
__all__ = [
|
|
152
|
+
"__version__",
|
|
153
|
+
# Agent
|
|
154
|
+
"Agent",
|
|
155
|
+
"AgentBuilder",
|
|
156
|
+
"AgentBuildError",
|
|
157
|
+
"AgentConfig",
|
|
158
|
+
"AgentLLMConfig",
|
|
159
|
+
"AgentMiddleware",
|
|
160
|
+
"LoggingMiddleware",
|
|
161
|
+
"ExecutionContext",
|
|
162
|
+
"get_execution_context",
|
|
163
|
+
"set_execution_context",
|
|
164
|
+
"ResponseWorkflow",
|
|
165
|
+
"StreamingResponseWorkflow",
|
|
166
|
+
"BaseDelegationResponseWorkflow",
|
|
167
|
+
"PublishFn",
|
|
168
|
+
# Config
|
|
169
|
+
"AgentSettings",
|
|
170
|
+
"BaseAgentSettings",
|
|
171
|
+
"SDKConfig",
|
|
172
|
+
"SettingsResolver",
|
|
173
|
+
"RuntimeConfigError",
|
|
174
|
+
"ConfigSource",
|
|
175
|
+
"StaticConfigSource",
|
|
176
|
+
"EnvConfigSource",
|
|
177
|
+
# Contracts
|
|
178
|
+
"StrictContract",
|
|
179
|
+
"InputContract",
|
|
180
|
+
"OutputContract",
|
|
181
|
+
"NodeContract",
|
|
182
|
+
"AgentContract",
|
|
183
|
+
"AgentMessage",
|
|
184
|
+
"AgentResponse",
|
|
185
|
+
"ResponseStatus",
|
|
186
|
+
"DelegationRequest",
|
|
187
|
+
"DelegationResponse",
|
|
188
|
+
"DelegationStatus",
|
|
189
|
+
# Errors
|
|
190
|
+
"AgentSDKError",
|
|
191
|
+
"ContractValidationError",
|
|
192
|
+
"InputValidationError",
|
|
193
|
+
"OutputValidationError",
|
|
194
|
+
"NodeExecutionError",
|
|
195
|
+
"RoutingError",
|
|
196
|
+
"ToolExecutionError",
|
|
197
|
+
"GraphExecutionError",
|
|
198
|
+
"ConfigSourceError",
|
|
199
|
+
"ErrorHandler",
|
|
200
|
+
"ErrorHandlerConfig",
|
|
201
|
+
"RetryPolicy",
|
|
202
|
+
"CircuitBreakerConfig",
|
|
203
|
+
# LLM protocol
|
|
204
|
+
"LLMCallable",
|
|
205
|
+
"StreamableLLMCallable",
|
|
206
|
+
"LLMResponse",
|
|
207
|
+
"TokenUsage",
|
|
208
|
+
"ToolCall",
|
|
209
|
+
"ToolSpec",
|
|
210
|
+
# Messaging
|
|
211
|
+
"AgentTaskMessage",
|
|
212
|
+
"ApiTaskMessage",
|
|
213
|
+
"ChatRequest",
|
|
214
|
+
"ChatResponse",
|
|
215
|
+
"StreamFragment",
|
|
216
|
+
"FileMessage",
|
|
217
|
+
"FileContent",
|
|
218
|
+
# Nodes
|
|
219
|
+
"BaseNode",
|
|
220
|
+
"NodeType",
|
|
221
|
+
"LLMNode",
|
|
222
|
+
"LLMNodeConfig",
|
|
223
|
+
"FunctionNode",
|
|
224
|
+
"AggregatorNode",
|
|
225
|
+
"AggregatorNodeConfig",
|
|
226
|
+
"DelegationNode",
|
|
227
|
+
"DelegationNodeConfig",
|
|
228
|
+
"DelegationTransport",
|
|
229
|
+
"NullDelegationTransport",
|
|
230
|
+
"PlannerNode",
|
|
231
|
+
# Routing
|
|
232
|
+
"Router",
|
|
233
|
+
"RoutingStrategy",
|
|
234
|
+
"StaticRoute",
|
|
235
|
+
"FieldValueStrategy",
|
|
236
|
+
"FieldPresenceStrategy",
|
|
237
|
+
"ConditionalStrategy",
|
|
238
|
+
"ConfidenceThresholdStrategy",
|
|
239
|
+
"CompositeStrategy",
|
|
240
|
+
"FanOutStrategy",
|
|
241
|
+
# RabbitMQ
|
|
242
|
+
"RabbitMQConfig",
|
|
243
|
+
"RabbitMQClient",
|
|
244
|
+
"RabbitMQConsumer",
|
|
245
|
+
"RabbitMQPublisher",
|
|
246
|
+
"RabbitMQRPCClient",
|
|
247
|
+
"RabbitMQDelegationTransport",
|
|
248
|
+
"AckPolicy",
|
|
249
|
+
# Runner
|
|
250
|
+
"AgentRunner",
|
|
251
|
+
"RunnerConfig",
|
|
252
|
+
# Workflows
|
|
253
|
+
"ChatResponseWorkflow",
|
|
254
|
+
"NullWorkflow",
|
|
255
|
+
# State
|
|
256
|
+
"ConversationStateProvider",
|
|
257
|
+
"InMemoryStateProvider",
|
|
258
|
+
"MemoryProvider",
|
|
259
|
+
"HistoryProvider",
|
|
260
|
+
"InMemoryHistory",
|
|
261
|
+
"Message",
|
|
262
|
+
]
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Agent module: the Agent executor, builder, and supporting runtime pieces."""
|
|
2
|
+
|
|
3
|
+
from sofias_sdk_lite.agent.agent import Agent
|
|
4
|
+
from sofias_sdk_lite.agent.agent_builder import AgentBuildError, AgentBuilder
|
|
5
|
+
from sofias_sdk_lite.agent.agent_config import AgentConfig, AgentLLMConfig
|
|
6
|
+
from sofias_sdk_lite.agent.execution_context import (
|
|
7
|
+
ExecutionContext,
|
|
8
|
+
TokenAccumulator,
|
|
9
|
+
get_execution_context,
|
|
10
|
+
set_execution_context,
|
|
11
|
+
)
|
|
12
|
+
from sofias_sdk_lite.agent.middleware import (
|
|
13
|
+
AgentMiddleware,
|
|
14
|
+
LoggingMiddleware,
|
|
15
|
+
TimingMiddleware,
|
|
16
|
+
)
|
|
17
|
+
from sofias_sdk_lite.agent.response_workflow import (
|
|
18
|
+
BaseDelegationResponseWorkflow,
|
|
19
|
+
PublishFn,
|
|
20
|
+
ResponseWorkflow,
|
|
21
|
+
StreamingResponseWorkflow,
|
|
22
|
+
)
|
|
23
|
+
from sofias_sdk_lite.agent.streaming import (
|
|
24
|
+
AgentCompleteEvent,
|
|
25
|
+
AgentErrorEvent,
|
|
26
|
+
AggregationResponseEvent,
|
|
27
|
+
NodeCompleteEvent,
|
|
28
|
+
NodeStartEvent,
|
|
29
|
+
StreamEvent,
|
|
30
|
+
TextChunkEvent,
|
|
31
|
+
ToolCallResultEvent,
|
|
32
|
+
ToolCallStartEvent,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
# Agent
|
|
37
|
+
"Agent",
|
|
38
|
+
"get_execution_context",
|
|
39
|
+
"set_execution_context",
|
|
40
|
+
"ExecutionContext",
|
|
41
|
+
"TokenAccumulator",
|
|
42
|
+
# Builder
|
|
43
|
+
"AgentBuilder",
|
|
44
|
+
"AgentBuildError",
|
|
45
|
+
# Config
|
|
46
|
+
"AgentConfig",
|
|
47
|
+
"AgentLLMConfig",
|
|
48
|
+
# Middleware
|
|
49
|
+
"AgentMiddleware",
|
|
50
|
+
"LoggingMiddleware",
|
|
51
|
+
"TimingMiddleware",
|
|
52
|
+
# Response workflow
|
|
53
|
+
"ResponseWorkflow",
|
|
54
|
+
"StreamingResponseWorkflow",
|
|
55
|
+
"BaseDelegationResponseWorkflow",
|
|
56
|
+
"PublishFn",
|
|
57
|
+
# Streaming events
|
|
58
|
+
"StreamEvent",
|
|
59
|
+
"TextChunkEvent",
|
|
60
|
+
"ToolCallStartEvent",
|
|
61
|
+
"ToolCallResultEvent",
|
|
62
|
+
"NodeStartEvent",
|
|
63
|
+
"NodeCompleteEvent",
|
|
64
|
+
"AgentCompleteEvent",
|
|
65
|
+
"AggregationResponseEvent",
|
|
66
|
+
"AgentErrorEvent",
|
|
67
|
+
]
|