swarmauri_agent_realtime 0.1.0__tar.gz
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.
- swarmauri_agent_realtime-0.1.0/LICENSE +13 -0
- swarmauri_agent_realtime-0.1.0/NOTICE +7 -0
- swarmauri_agent_realtime-0.1.0/PKG-INFO +320 -0
- swarmauri_agent_realtime-0.1.0/README.md +298 -0
- swarmauri_agent_realtime-0.1.0/pyproject.toml +84 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/RealtimeAgent.py +65 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/RealtimeAgentRunResult.py +12 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/__init__.py +4 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/LiveSessionEntry.py +13 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/LiveSessionPool.py +143 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/RealtimeToolCoordinator.py +75 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/RealtimeTurn.py +15 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/RealtimeTurnAccumulator.py +42 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/SwarmauriConversationAdapter.py +19 -0
- swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/__init__.py +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Jacob Stewart
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: swarmauri_agent_realtime
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Provider-neutral realtime multimodal agent for Swarmauri live models.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
License-File: NOTICE
|
|
8
|
+
Keywords: swarmauri,agent,realtime,audio,tools,multimodal
|
|
9
|
+
Author: Jacob Stewart
|
|
10
|
+
Author-email: jacob@swarmauri.com
|
|
11
|
+
Requires-Python: >=3.10,<3.15
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Requires-Dist: swarmauri_base (>=0.11.0,<0.12)
|
|
19
|
+
Requires-Dist: swarmauri_core (>=0.11.0,<0.12)
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# swarmauri_agent_realtime
|
|
23
|
+
|
|
24
|
+
<!-- readme-standards:begin branding -->
|
|
25
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
26
|
+
<p align="center"><strong>swarmauri_agent_realtime</strong></p>
|
|
27
|
+
<p align="center">Provider-neutral realtime multimodal agent for Swarmauri live models.</p>
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="https://pypi.org/project/swarmauri_agent_realtime/"><img alt="pypi: swarmauri_agent_realtime" src="https://img.shields.io/pypi/v/swarmauri_agent_realtime?labelColor=1E293B&color=1D4ED8"></a>
|
|
30
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=1E293B&color=4338CA"></a>
|
|
31
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
32
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
33
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
34
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
35
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
36
|
+
</p>
|
|
37
|
+
<p align="center">
|
|
38
|
+
<a href="https://pypi.org/project/swarmauri_agent_realtime/"><img alt="Monthly PyPI downloads: swarmauri_agent_realtime" src="https://img.shields.io/pypi/dm/swarmauri_agent_realtime?labelColor=1E293B&color=0E7490"></a>
|
|
39
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md"><img alt="README hits: swarmauri_agent_realtime" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_agent_realtime/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
40
|
+
</p>
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
43
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
44
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
45
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
46
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
47
|
+
</p>
|
|
48
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
49
|
+
<!-- readme-standards:end branding -->
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Overview
|
|
54
|
+
|
|
55
|
+
### Summary
|
|
56
|
+
|
|
57
|
+
[](https://pypi.org/project/swarmauri_agent_realtime/) [](https://pypi.org/project/swarmauri_agent_realtime/) [](LICENSE) [](https://pepy.tech/project/swarmauri_agent_realtime) [](https://hits.sh/github.com/swarmauri/swarmauri-sdk/)
|
|
58
|
+
|
|
59
|
+
### Why This Package
|
|
60
|
+
|
|
61
|
+
`swarmauri_agent_realtime` isolates this responsibility: Provider-neutral realtime multimodal agent for Swarmauri live models. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) exposes `RealtimeAgent`, `RealtimeAgentRunResult`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
62
|
+
|
|
63
|
+
### When to Use
|
|
64
|
+
|
|
65
|
+
Choose `swarmauri_agent_realtime` when your integration needs provider-neutral realtime multimodal agent for Swarmauri live models. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
66
|
+
|
|
67
|
+
### Features
|
|
68
|
+
|
|
69
|
+
- Provider-neutral live-model orchestration.
|
|
70
|
+
- Conversation bridging, function calls, interruption, and typed events.
|
|
71
|
+
- One provider connection per conversation through `LiveSessionPool`.
|
|
72
|
+
|
|
73
|
+
### Non-Goals
|
|
74
|
+
|
|
75
|
+
`swarmauri_agent_realtime` owns provider-neutral realtime multimodal agent for Swarmauri live models. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Getting Started
|
|
80
|
+
|
|
81
|
+
### Prerequisites
|
|
82
|
+
|
|
83
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) declares runtime dependencies including `swarmauri-core`, `swarmauri-base`. Read the example’s inputs and service requirements before execution.
|
|
84
|
+
|
|
85
|
+
### Installation
|
|
86
|
+
|
|
87
|
+
`uv add swarmauri_agent_realtime` or `pip install swarmauri_agent_realtime`.
|
|
88
|
+
|
|
89
|
+
#### uv
|
|
90
|
+
|
|
91
|
+
<!-- readme-standards:begin installation.uv -->
|
|
92
|
+
```bash
|
|
93
|
+
uv add swarmauri_agent_realtime
|
|
94
|
+
```
|
|
95
|
+
<!-- readme-standards:end installation.uv -->
|
|
96
|
+
|
|
97
|
+
#### pip
|
|
98
|
+
|
|
99
|
+
<!-- readme-standards:begin installation.pip -->
|
|
100
|
+
```bash
|
|
101
|
+
python -m pip install swarmauri_agent_realtime
|
|
102
|
+
```
|
|
103
|
+
<!-- readme-standards:end installation.pip -->
|
|
104
|
+
|
|
105
|
+
#### Poetry
|
|
106
|
+
|
|
107
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
108
|
+
```bash
|
|
109
|
+
poetry add swarmauri_agent_realtime
|
|
110
|
+
```
|
|
111
|
+
<!-- readme-standards:end installation.poetry -->
|
|
112
|
+
|
|
113
|
+
### Quick Start
|
|
114
|
+
|
|
115
|
+
#### Example
|
|
116
|
+
|
|
117
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
118
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/docs/readme/quick_start.py).
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import importlib
|
|
122
|
+
|
|
123
|
+
package = importlib.import_module("swarmauri_agent_realtime")
|
|
124
|
+
assert package.__name__ == "swarmauri_agent_realtime"
|
|
125
|
+
```
|
|
126
|
+
<!-- readme-standards:end example.quick-start -->
|
|
127
|
+
|
|
128
|
+
#### Expected Result
|
|
129
|
+
|
|
130
|
+
This quick start is explicitly an import smoke check for `swarmauri_agent_realtime`. It confirms that the documented namespace loads; it does not demonstrate or certify a complete application workflow. The detailed source and retained usage guidance below describe the integration boundary.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Usage
|
|
135
|
+
|
|
136
|
+
### Common Workflows
|
|
137
|
+
|
|
138
|
+
<!-- readme-standards:begin example.usage -->
|
|
139
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/docs/readme/usage.py).
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
import importlib
|
|
143
|
+
|
|
144
|
+
package = importlib.import_module("swarmauri_agent_realtime")
|
|
145
|
+
assert package.__name__ == "swarmauri_agent_realtime"
|
|
146
|
+
```
|
|
147
|
+
<!-- readme-standards:end example.usage -->
|
|
148
|
+
|
|
149
|
+
Construct `RealtimeAgent(live_model=...)`, send typed live inputs, and consume events or use `run`/`arun` for one completed turn.
|
|
150
|
+
|
|
151
|
+
### Configuration
|
|
152
|
+
|
|
153
|
+
Configure `swarmauri_agent_realtime` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
154
|
+
|
|
155
|
+
### Error Handling
|
|
156
|
+
|
|
157
|
+
The inspected `swarmauri_agent_realtime` source raises `KeyError`, `RuntimeError`, `ValueError`. Handle these at the calling boundary and consult the implementation for the triggering conditions.
|
|
158
|
+
|
|
159
|
+
### Best Practices
|
|
160
|
+
|
|
161
|
+
Use the explicit `swarmauri_agent_realtime` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `RealtimeAgent`, `RealtimeAgentRunResult`; an import or successful installation alone does not establish its runtime guarantees.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Package Boundary
|
|
166
|
+
|
|
167
|
+
### What It Owns
|
|
168
|
+
|
|
169
|
+
`swarmauri_agent_realtime` is located in `standards` and owns provider-neutral realtime multimodal agent for Swarmauri live models. Source-declared APIs include `RealtimeAgent`, `RealtimeAgentRunResult`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) records its direct dependency boundary.
|
|
170
|
+
|
|
171
|
+
### Public API and Import Surfaces
|
|
172
|
+
|
|
173
|
+
Import namespace: `swarmauri_agent_realtime`.
|
|
174
|
+
|
|
175
|
+
Source-declared exports or types: `RealtimeAgent`, `RealtimeAgentRunResult`.
|
|
176
|
+
|
|
177
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
178
|
+
|
|
179
|
+
### Entry Points
|
|
180
|
+
|
|
181
|
+
<!-- readme-standards:begin entry-points -->
|
|
182
|
+
- `swarmauri.agents` → `RealtimeAgent` → `swarmauri_agent_realtime:RealtimeAgent`
|
|
183
|
+
<!-- readme-standards:end entry-points -->
|
|
184
|
+
|
|
185
|
+
### Injected Dependencies
|
|
186
|
+
|
|
187
|
+
The direct installation dependencies of `swarmauri_agent_realtime` are `swarmauri-core`, `swarmauri-base`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py).
|
|
188
|
+
|
|
189
|
+
### Protocol Consumers
|
|
190
|
+
|
|
191
|
+
No direct package-manifest dependency on `swarmauri_agent_realtime` was found in the audited three-repository inventory. External consumers may still use its documented imports or commands.
|
|
192
|
+
|
|
193
|
+
### Extensions
|
|
194
|
+
|
|
195
|
+
For `swarmauri_agent_realtime`, use the source-declared public interfaces (`RealtimeAgent`, `RealtimeAgentRunResult`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Operations and Readiness
|
|
200
|
+
|
|
201
|
+
### Operational Requirements
|
|
202
|
+
|
|
203
|
+
Operate `swarmauri_agent_realtime` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
204
|
+
|
|
205
|
+
### Health and Observability
|
|
206
|
+
|
|
207
|
+
This README does not establish a standalone health endpoint for `swarmauri_agent_realtime`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
208
|
+
|
|
209
|
+
### Security and Resource Limits
|
|
210
|
+
|
|
211
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py). The `swarmauri_agent_realtime` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
212
|
+
|
|
213
|
+
### Compatibility
|
|
214
|
+
|
|
215
|
+
This source version of `swarmauri_agent_realtime` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Verification
|
|
220
|
+
|
|
221
|
+
### Tests
|
|
222
|
+
|
|
223
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_agent_realtime` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
224
|
+
|
|
225
|
+
- [tests/unit/test_live_session_pool.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_live_session_pool.py)
|
|
226
|
+
- [tests/unit/test_realtime_turn_services.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_realtime_turn_services.py)
|
|
227
|
+
|
|
228
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
229
|
+
|
|
230
|
+
### Certification Status
|
|
231
|
+
|
|
232
|
+
No external certification is asserted for `swarmauri_agent_realtime` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
233
|
+
|
|
234
|
+
### Evidence
|
|
235
|
+
|
|
236
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## FAQ
|
|
241
|
+
|
|
242
|
+
### Why
|
|
243
|
+
|
|
244
|
+
**Why select this package?** `swarmauri_agent_realtime` provides provider-neutral realtime multimodal agent for Swarmauri live models; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
245
|
+
|
|
246
|
+
### How
|
|
247
|
+
|
|
248
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_agent_realtime`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) for the exact types and signatures involved.
|
|
249
|
+
|
|
250
|
+
### When
|
|
251
|
+
|
|
252
|
+
**When should I validate an upgrade?** Recheck `swarmauri_agent_realtime` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Documentation and Related Packages
|
|
257
|
+
|
|
258
|
+
### More Documentation
|
|
259
|
+
|
|
260
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) provide the supporting context for `swarmauri_agent_realtime`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
261
|
+
|
|
262
|
+
### Related Packages
|
|
263
|
+
|
|
264
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
265
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
266
|
+
|
|
267
|
+
### Project Links
|
|
268
|
+
|
|
269
|
+
<!-- readme-standards:begin project-links -->
|
|
270
|
+
- [pypi: swarmauri_agent_realtime](https://pypi.org/project/swarmauri_agent_realtime/)
|
|
271
|
+
<!-- readme-standards:end project-links -->
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Contributing
|
|
276
|
+
|
|
277
|
+
### How to Contribute
|
|
278
|
+
|
|
279
|
+
Follow the [contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md) and include a focused example or regression for changes to `swarmauri_agent_realtime`. Keep package behavior, its documented boundary, and its tests aligned.
|
|
280
|
+
|
|
281
|
+
### Development Setup
|
|
282
|
+
|
|
283
|
+
Work from the `pkgs/40-standards/swarmauri_agent_realtime` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
284
|
+
|
|
285
|
+
### Notes for Maintainers
|
|
286
|
+
|
|
287
|
+
Edit authored prose directly in this `swarmauri_agent_realtime` README. Update source examples in `docs/readme/`, then run `readme-standards render --root . --write` from the package directory and review the diff. Required headings and generated blocks come from package-guide-v1.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Governance
|
|
292
|
+
|
|
293
|
+
### Ownership and Decision Making
|
|
294
|
+
|
|
295
|
+
Changes to `swarmauri_agent_realtime` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
296
|
+
|
|
297
|
+
### Standards and Policies
|
|
298
|
+
|
|
299
|
+
`swarmauri_agent_realtime` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
300
|
+
|
|
301
|
+
### Lifecycle and Migration
|
|
302
|
+
|
|
303
|
+
The `swarmauri_agent_realtime` source version is `0.1.0`.
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## License and Attribution
|
|
308
|
+
|
|
309
|
+
### License
|
|
310
|
+
|
|
311
|
+
<!-- readme-standards:begin license -->
|
|
312
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/LICENSE).
|
|
313
|
+
<!-- readme-standards:end license -->
|
|
314
|
+
|
|
315
|
+
### Notices
|
|
316
|
+
|
|
317
|
+
<!-- readme-standards:begin notices -->
|
|
318
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/NOTICE) for attribution.
|
|
319
|
+
<!-- readme-standards:end notices -->
|
|
320
|
+
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# swarmauri_agent_realtime
|
|
2
|
+
|
|
3
|
+
<!-- readme-standards:begin branding -->
|
|
4
|
+
<p align="center"><a href="https://github.com/swarmauri/swarmauri-sdk"><img src="https://raw.githubusercontent.com/swarmauri/swarmauri-sdk/master/assets/swarmauri.brand.theme.svg" alt="Swarmauri SDK" width="300"></a></p>
|
|
5
|
+
<p align="center"><strong>swarmauri_agent_realtime</strong></p>
|
|
6
|
+
<p align="center">Provider-neutral realtime multimodal agent for Swarmauri live models.</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/swarmauri_agent_realtime/"><img alt="pypi: swarmauri_agent_realtime" src="https://img.shields.io/pypi/v/swarmauri_agent_realtime?labelColor=1E293B&color=1D4ED8"></a>
|
|
9
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Source version: 0.1.0" src="https://img.shields.io/static/v1?label=Source%20version&message=0.1.0&labelColor=1E293B&color=4338CA"></a>
|
|
10
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Python: >=3.10,<3.15" src="https://img.shields.io/static/v1?label=Python&message=%3E%3D3.10%2C%3C3.15&labelColor=1E293B&color=0F766E"></a>
|
|
11
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml"><img alt="Layer: standards" src="https://img.shields.io/static/v1?label=Layer&message=standards&labelColor=1E293B&color=6D28D9"></a>
|
|
12
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&message=active&labelColor=1E293B&color=166534"></a>
|
|
13
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&message=Apache-2.0&labelColor=1E293B&color=86198F"></a>
|
|
14
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&message=attribution&labelColor=1E293B&color=86198F"></a>
|
|
15
|
+
</p>
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://pypi.org/project/swarmauri_agent_realtime/"><img alt="Monthly PyPI downloads: swarmauri_agent_realtime" src="https://img.shields.io/pypi/dm/swarmauri_agent_realtime?labelColor=1E293B&color=0E7490"></a>
|
|
18
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md"><img alt="README hits: swarmauri_agent_realtime" src="https://hits.sh/github.com/swarmauri/swarmauri-sdk/pkgs/40-standards/swarmauri_agent_realtime/README.md.svg?label=README%20hits&labelColor=1E293B&color=0E7490"></a>
|
|
19
|
+
</p>
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&message=CI%20gate&labelColor=1E293B&color=1D4ED8"></a>
|
|
22
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_readme_sources.py"><img alt="Tests: example source" src="https://img.shields.io/static/v1?label=Tests&message=example%20source&labelColor=1E293B&color=0F766E"></a>
|
|
23
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&message=not%20certified&labelColor=1E293B&color=92400E"></a>
|
|
24
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&message=repository%20policy&labelColor=1E293B&color=4338CA"></a>
|
|
25
|
+
<a href="https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&message=source%20and%20CI&labelColor=1E293B&color=6D28D9"></a>
|
|
26
|
+
</p>
|
|
27
|
+
<p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
|
|
28
|
+
<!-- readme-standards:end branding -->
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Overview
|
|
33
|
+
|
|
34
|
+
### Summary
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/swarmauri_agent_realtime/) [](https://pypi.org/project/swarmauri_agent_realtime/) [](LICENSE) [](https://pepy.tech/project/swarmauri_agent_realtime) [](https://hits.sh/github.com/swarmauri/swarmauri-sdk/)
|
|
37
|
+
|
|
38
|
+
### Why This Package
|
|
39
|
+
|
|
40
|
+
`swarmauri_agent_realtime` isolates this responsibility: Provider-neutral realtime multimodal agent for Swarmauri live models. Its [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) exposes `RealtimeAgent`, `RealtimeAgentRunResult`, allowing consumers to select this package without treating adjacent packages as part of its public contract.
|
|
41
|
+
|
|
42
|
+
### When to Use
|
|
43
|
+
|
|
44
|
+
Choose `swarmauri_agent_realtime` when your integration needs provider-neutral realtime multimodal agent for Swarmauri live models. Match the imports below to your application boundary and install its declared dependencies before using the example.
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
- Provider-neutral live-model orchestration.
|
|
49
|
+
- Conversation bridging, function calls, interruption, and typed events.
|
|
50
|
+
- One provider connection per conversation through `LiveSessionPool`.
|
|
51
|
+
|
|
52
|
+
### Non-Goals
|
|
53
|
+
|
|
54
|
+
`swarmauri_agent_realtime` owns provider-neutral realtime multimodal agent for Swarmauri live models. Its imports do not by themselves configure credentials, deploy a service, or certify the behavior of its consumers. Dependencies and neighboring packages retain their own documented responsibilities.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Getting Started
|
|
59
|
+
|
|
60
|
+
### Prerequisites
|
|
61
|
+
|
|
62
|
+
Python `>=3.10,<3.15` is required. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) declares runtime dependencies including `swarmauri-core`, `swarmauri-base`. Read the example’s inputs and service requirements before execution.
|
|
63
|
+
|
|
64
|
+
### Installation
|
|
65
|
+
|
|
66
|
+
`uv add swarmauri_agent_realtime` or `pip install swarmauri_agent_realtime`.
|
|
67
|
+
|
|
68
|
+
#### uv
|
|
69
|
+
|
|
70
|
+
<!-- readme-standards:begin installation.uv -->
|
|
71
|
+
```bash
|
|
72
|
+
uv add swarmauri_agent_realtime
|
|
73
|
+
```
|
|
74
|
+
<!-- readme-standards:end installation.uv -->
|
|
75
|
+
|
|
76
|
+
#### pip
|
|
77
|
+
|
|
78
|
+
<!-- readme-standards:begin installation.pip -->
|
|
79
|
+
```bash
|
|
80
|
+
python -m pip install swarmauri_agent_realtime
|
|
81
|
+
```
|
|
82
|
+
<!-- readme-standards:end installation.pip -->
|
|
83
|
+
|
|
84
|
+
#### Poetry
|
|
85
|
+
|
|
86
|
+
<!-- readme-standards:begin installation.poetry -->
|
|
87
|
+
```bash
|
|
88
|
+
poetry add swarmauri_agent_realtime
|
|
89
|
+
```
|
|
90
|
+
<!-- readme-standards:end installation.poetry -->
|
|
91
|
+
|
|
92
|
+
### Quick Start
|
|
93
|
+
|
|
94
|
+
#### Example
|
|
95
|
+
|
|
96
|
+
<!-- readme-standards:begin example.quick-start -->
|
|
97
|
+
Source: [docs/readme/quick_start.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/docs/readme/quick_start.py).
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
import importlib
|
|
101
|
+
|
|
102
|
+
package = importlib.import_module("swarmauri_agent_realtime")
|
|
103
|
+
assert package.__name__ == "swarmauri_agent_realtime"
|
|
104
|
+
```
|
|
105
|
+
<!-- readme-standards:end example.quick-start -->
|
|
106
|
+
|
|
107
|
+
#### Expected Result
|
|
108
|
+
|
|
109
|
+
This quick start is explicitly an import smoke check for `swarmauri_agent_realtime`. It confirms that the documented namespace loads; it does not demonstrate or certify a complete application workflow. The detailed source and retained usage guidance below describe the integration boundary.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
### Common Workflows
|
|
116
|
+
|
|
117
|
+
<!-- readme-standards:begin example.usage -->
|
|
118
|
+
Source: [docs/readme/usage.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/docs/readme/usage.py).
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
import importlib
|
|
122
|
+
|
|
123
|
+
package = importlib.import_module("swarmauri_agent_realtime")
|
|
124
|
+
assert package.__name__ == "swarmauri_agent_realtime"
|
|
125
|
+
```
|
|
126
|
+
<!-- readme-standards:end example.usage -->
|
|
127
|
+
|
|
128
|
+
Construct `RealtimeAgent(live_model=...)`, send typed live inputs, and consume events or use `run`/`arun` for one completed turn.
|
|
129
|
+
|
|
130
|
+
### Configuration
|
|
131
|
+
|
|
132
|
+
Configure `swarmauri_agent_realtime` through the APIs in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py); its [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) describes installation requirements, not an implicit service configuration. No additional package-global configuration contract is inferred from dependencies.
|
|
133
|
+
|
|
134
|
+
### Error Handling
|
|
135
|
+
|
|
136
|
+
The inspected `swarmauri_agent_realtime` source raises `KeyError`, `RuntimeError`, `ValueError`. Handle these at the calling boundary and consult the implementation for the triggering conditions.
|
|
137
|
+
|
|
138
|
+
### Best Practices
|
|
139
|
+
|
|
140
|
+
Use the explicit `swarmauri_agent_realtime` imports documented below and keep collaborator configuration with the caller. Run the package’s relevant tests after changing `RealtimeAgent`, `RealtimeAgentRunResult`; an import or successful installation alone does not establish its runtime guarantees.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Package Boundary
|
|
145
|
+
|
|
146
|
+
### What It Owns
|
|
147
|
+
|
|
148
|
+
`swarmauri_agent_realtime` is located in `standards` and owns provider-neutral realtime multimodal agent for Swarmauri live models. Source-declared APIs include `RealtimeAgent`, `RealtimeAgentRunResult`. The [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) records its direct dependency boundary.
|
|
149
|
+
|
|
150
|
+
### Public API and Import Surfaces
|
|
151
|
+
|
|
152
|
+
Import namespace: `swarmauri_agent_realtime`.
|
|
153
|
+
|
|
154
|
+
Source-declared exports or types: `RealtimeAgent`, `RealtimeAgentRunResult`.
|
|
155
|
+
|
|
156
|
+
Inspect [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) for exact signatures; this inventory does not designate every internal module as stable.
|
|
157
|
+
|
|
158
|
+
### Entry Points
|
|
159
|
+
|
|
160
|
+
<!-- readme-standards:begin entry-points -->
|
|
161
|
+
- `swarmauri.agents` → `RealtimeAgent` → `swarmauri_agent_realtime:RealtimeAgent`
|
|
162
|
+
<!-- readme-standards:end entry-points -->
|
|
163
|
+
|
|
164
|
+
### Injected Dependencies
|
|
165
|
+
|
|
166
|
+
The direct installation dependencies of `swarmauri_agent_realtime` are `swarmauri-core`, `swarmauri-base`. These declarations do not imply automatic provider selection. Pass collaborators through the explicit constructors or call signatures in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py).
|
|
167
|
+
|
|
168
|
+
### Protocol Consumers
|
|
169
|
+
|
|
170
|
+
No direct package-manifest dependency on `swarmauri_agent_realtime` was found in the audited three-repository inventory. External consumers may still use its documented imports or commands.
|
|
171
|
+
|
|
172
|
+
### Extensions
|
|
173
|
+
|
|
174
|
+
For `swarmauri_agent_realtime`, use the source-declared public interfaces (`RealtimeAgent`, `RealtimeAgentRunResult`) when composing or extending behavior. Its entry-point section below is authoritative for registered plugins; no additional extension loader is inferred from the package name.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Operations and Readiness
|
|
179
|
+
|
|
180
|
+
### Operational Requirements
|
|
181
|
+
|
|
182
|
+
Operate `swarmauri_agent_realtime` according to its actual entry points and collaborators. The dependency and Python requirements in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) are prerequisites; deployment topology, credentials, and readiness remain the responsibility of the consuming application unless explicitly documented above.
|
|
183
|
+
|
|
184
|
+
### Health and Observability
|
|
185
|
+
|
|
186
|
+
This README does not establish a standalone health endpoint for `swarmauri_agent_realtime`. Observe the concrete caller’s results, exceptions, and existing test reports. An application that embeds this package must define its own health and telemetry contract.
|
|
187
|
+
|
|
188
|
+
### Security and Resource Limits
|
|
189
|
+
|
|
190
|
+
Apply the input, credential, and resource constraints implemented in [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py). The `swarmauri_agent_realtime` README gate is a documentation check, not a security review or a substitute for the implementation’s limits and caller authorization.
|
|
191
|
+
|
|
192
|
+
### Compatibility
|
|
193
|
+
|
|
194
|
+
This source version of `swarmauri_agent_realtime` declares Python `>=3.10,<3.15`. Consult its dependency constraints before upgrading. Source-version and registry-version badges have separate meanings; this migration makes no additional platform or interoperability certification claim.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Verification
|
|
199
|
+
|
|
200
|
+
### Tests
|
|
201
|
+
|
|
202
|
+
Run `python -m pytest tests/unit/test_readme_sources.py` from the `swarmauri_agent_realtime` package directory for the maintained example source checks (Python compilation and non-Python file presence). Existing package tests include:
|
|
203
|
+
|
|
204
|
+
- [tests/unit/test_live_session_pool.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_live_session_pool.py)
|
|
205
|
+
- [tests/unit/test_realtime_turn_services.py](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_realtime_turn_services.py)
|
|
206
|
+
|
|
207
|
+
The repository README gate also checks the required heading tree, metadata, managed fragments, and referenced files.
|
|
208
|
+
|
|
209
|
+
### Certification Status
|
|
210
|
+
|
|
211
|
+
No external certification is asserted for `swarmauri_agent_realtime` by this documentation migration. README conformance, example syntax, runtime tests, and protocol or security certification are distinct evidence scopes.
|
|
212
|
+
|
|
213
|
+
### Evidence
|
|
214
|
+
|
|
215
|
+
The [README standards CI](https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml) records mechanical documentation results for its tested commit. The [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) and example sources support the package-boundary description; external runtime behavior requires its own test evidence.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## FAQ
|
|
220
|
+
|
|
221
|
+
### Why
|
|
222
|
+
|
|
223
|
+
**Why select this package?** `swarmauri_agent_realtime` provides provider-neutral realtime multimodal agent for Swarmauri live models; use its own API boundary rather than assuming neighboring packages are bundled or configured automatically.
|
|
224
|
+
|
|
225
|
+
### How
|
|
226
|
+
|
|
227
|
+
**How do I start?** Install or synchronize the environment under Getting Started, follow the maintained example for `swarmauri_agent_realtime`, and consult [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py) for the exact types and signatures involved.
|
|
228
|
+
|
|
229
|
+
### When
|
|
230
|
+
|
|
231
|
+
**When should I validate an upgrade?** Recheck `swarmauri_agent_realtime` whenever its source version, declared collaborators, configuration, or caller changes. Run relevant behavioral tests in addition to the README gate before promotion.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Documentation and Related Packages
|
|
236
|
+
|
|
237
|
+
### More Documentation
|
|
238
|
+
|
|
239
|
+
The [repository contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md), [package source](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/swarmauri_agent_realtime/_internal/__init__.py), and [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml) provide the supporting context for `swarmauri_agent_realtime`. The [README policy](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md) defines the common document structure.
|
|
240
|
+
|
|
241
|
+
### Related Packages
|
|
242
|
+
|
|
243
|
+
- [swarmauri_base](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/20-bases/swarmauri_base/README.md): Reusable Swarmauri base classes, mixins, and dynamic Pydantic component models for composable intelligence infrastructure.
|
|
244
|
+
- [swarmauri_core](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/10-interfaces/swarmauri_core/README.md): Core interface contracts and shared types for Swarmauri composable intelligence infrastructure components.
|
|
245
|
+
|
|
246
|
+
### Project Links
|
|
247
|
+
|
|
248
|
+
<!-- readme-standards:begin project-links -->
|
|
249
|
+
- [pypi: swarmauri_agent_realtime](https://pypi.org/project/swarmauri_agent_realtime/)
|
|
250
|
+
<!-- readme-standards:end project-links -->
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Contributing
|
|
255
|
+
|
|
256
|
+
### How to Contribute
|
|
257
|
+
|
|
258
|
+
Follow the [contribution guide](https://github.com/swarmauri/swarmauri-sdk/blob/master/CONTRIBUTING.md) and include a focused example or regression for changes to `swarmauri_agent_realtime`. Keep package behavior, its documented boundary, and its tests aligned.
|
|
259
|
+
|
|
260
|
+
### Development Setup
|
|
261
|
+
|
|
262
|
+
Work from the `pkgs/40-standards/swarmauri_agent_realtime` checkout. Synchronize its declared development environment with uv, then run the relevant package tests and `python -m pytest tests/unit/test_readme_sources.py`. The repository’s dedicated README job installs `readme-standards==0.1.3` without resolving unrelated runtime packages.
|
|
263
|
+
|
|
264
|
+
### Notes for Maintainers
|
|
265
|
+
|
|
266
|
+
Edit authored prose directly in this `swarmauri_agent_realtime` README. Update source examples in `docs/readme/`, then run `readme-standards render --root . --write` from the package directory and review the diff. Required headings and generated blocks come from package-guide-v1.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Governance
|
|
271
|
+
|
|
272
|
+
### Ownership and Decision Making
|
|
273
|
+
|
|
274
|
+
Changes to `swarmauri_agent_realtime` follow the maintainer review process of [swarmauri/swarmauri-sdk](https://github.com/swarmauri/swarmauri-sdk) and its contribution guide. Author attribution remains in the [manifest](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/pyproject.toml); this README does not assign new publishing or administrative authority.
|
|
275
|
+
|
|
276
|
+
### Standards and Policies
|
|
277
|
+
|
|
278
|
+
`swarmauri_agent_realtime` follows the versioned [package-guide-v1 outline](https://github.com/groupsum/readme-standards/blob/master/docs/outline.md). All fixed headings, hierarchy, order, separators, and package-specific branding are checked by CI; reviewers assess the accuracy and usefulness of authored claims.
|
|
279
|
+
|
|
280
|
+
### Lifecycle and Migration
|
|
281
|
+
|
|
282
|
+
The `swarmauri_agent_realtime` source version is `0.1.0`.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## License and Attribution
|
|
287
|
+
|
|
288
|
+
### License
|
|
289
|
+
|
|
290
|
+
<!-- readme-standards:begin license -->
|
|
291
|
+
Licensed under `Apache-2.0`. See [LICENSE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/LICENSE).
|
|
292
|
+
<!-- readme-standards:end license -->
|
|
293
|
+
|
|
294
|
+
### Notices
|
|
295
|
+
|
|
296
|
+
<!-- readme-standards:begin notices -->
|
|
297
|
+
See [NOTICE](https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/NOTICE) for attribution.
|
|
298
|
+
<!-- readme-standards:end notices -->
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "swarmauri_agent_realtime"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Provider-neutral realtime multimodal agent for Swarmauri live models."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
8
|
+
license = "Apache-2.0"
|
|
9
|
+
dependencies = ["swarmauri_core<0.12,>=0.11.0", "swarmauri_base<0.12,>=0.11.0"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 1 - Planning",
|
|
12
|
+
"Programming Language :: Python :: 3.10",
|
|
13
|
+
"Programming Language :: Python :: 3.11",
|
|
14
|
+
"Programming Language :: Python :: 3.12",
|
|
15
|
+
"Programming Language :: Python :: 3.13",
|
|
16
|
+
"Programming Language :: Python :: 3.14",
|
|
17
|
+
]
|
|
18
|
+
keywords = ["swarmauri", "agent", "realtime", "audio", "tools", "multimodal"]
|
|
19
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
20
|
+
[tool.uv.sources]
|
|
21
|
+
swarmauri_core = { workspace = true }
|
|
22
|
+
swarmauri_base = { workspace = true }
|
|
23
|
+
|
|
24
|
+
[tool.readme_standards]
|
|
25
|
+
policy = "package-guide-v1"
|
|
26
|
+
readme = "README.md"
|
|
27
|
+
brand = "swarmauri"
|
|
28
|
+
brand_catalog = "../../../tools/readme/brands.toml"
|
|
29
|
+
repository = "https://github.com/swarmauri/swarmauri-sdk"
|
|
30
|
+
ref = "master"
|
|
31
|
+
package_path = "pkgs/40-standards/swarmauri_agent_realtime"
|
|
32
|
+
layer = "standards"
|
|
33
|
+
lifecycle = "active"
|
|
34
|
+
license_file = "LICENSE"
|
|
35
|
+
notice_file = "NOTICE"
|
|
36
|
+
|
|
37
|
+
[tool.readme_standards.distributions.pypi]
|
|
38
|
+
name = "swarmauri_agent_realtime"
|
|
39
|
+
published = true
|
|
40
|
+
|
|
41
|
+
[tool.readme_standards.examples.quick_start]
|
|
42
|
+
source = "docs/readme/quick_start.py"
|
|
43
|
+
test = "tests/unit/test_readme_sources.py"
|
|
44
|
+
language = "python"
|
|
45
|
+
expected_exit_code = 0
|
|
46
|
+
|
|
47
|
+
[tool.readme_standards.examples.usage]
|
|
48
|
+
source = "docs/readme/usage.py"
|
|
49
|
+
test = "tests/unit/test_readme_sources.py"
|
|
50
|
+
language = "python"
|
|
51
|
+
expected_exit_code = 0
|
|
52
|
+
|
|
53
|
+
[tool.readme_standards.statuses.readme]
|
|
54
|
+
label = "CI gate"
|
|
55
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
56
|
+
|
|
57
|
+
[tool.readme_standards.statuses.tests]
|
|
58
|
+
label = "example source"
|
|
59
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/tests/unit/test_readme_sources.py"
|
|
60
|
+
|
|
61
|
+
[tool.readme_standards.statuses.certification]
|
|
62
|
+
label = "not certified"
|
|
63
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/pkgs/40-standards/swarmauri_agent_realtime/README.md#certification-status"
|
|
64
|
+
|
|
65
|
+
[tool.readme_standards.statuses.governance]
|
|
66
|
+
label = "repository policy"
|
|
67
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/blob/master/tools/readme/POLICY.md"
|
|
68
|
+
|
|
69
|
+
[tool.readme_standards.statuses.evidence]
|
|
70
|
+
label = "source and CI"
|
|
71
|
+
url = "https://github.com/swarmauri/swarmauri-sdk/actions/workflows/readme-standards.yml"
|
|
72
|
+
[project.entry-points."swarmauri.agents"]
|
|
73
|
+
RealtimeAgent = "swarmauri_agent_realtime:RealtimeAgent"
|
|
74
|
+
[build-system]
|
|
75
|
+
requires = ["poetry-core>=1.8.0"]
|
|
76
|
+
build-backend = "poetry.core.masonry.api"
|
|
77
|
+
[dependency-groups]
|
|
78
|
+
dev = ["pytest>=8.0", "pytest-asyncio>=0.24", "ruff>=0.9.9", "readme-standards==0.1.3; python_version >= \"3.11\""]
|
|
79
|
+
|
|
80
|
+
[tool.ruff]
|
|
81
|
+
extend = "../../pyproject.toml"
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint]
|
|
84
|
+
ignore = ["BLE001", "N999"]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
|
|
3
|
+
from swarmauri_base.agents.RealtimeAgentBase import RealtimeAgentBase
|
|
4
|
+
from swarmauri_base.live_models.events.ToolCallEvent import ToolCallEvent
|
|
5
|
+
from swarmauri_base.live_models.events.ToolCancellationEvent import (
|
|
6
|
+
ToolCancellationEvent,
|
|
7
|
+
)
|
|
8
|
+
from swarmauri_base.live_models.events.TurnCompleteEvent import (
|
|
9
|
+
TurnCompleteEvent,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from ._internal.RealtimeToolCoordinator import RealtimeToolCoordinator
|
|
13
|
+
from ._internal.RealtimeTurnAccumulator import RealtimeTurnAccumulator
|
|
14
|
+
from ._internal.SwarmauriConversationAdapter import (
|
|
15
|
+
SwarmauriConversationAdapter,
|
|
16
|
+
)
|
|
17
|
+
from .RealtimeAgentRunResult import RealtimeAgentRunResult
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RealtimeAgent(RealtimeAgentBase):
|
|
21
|
+
type: Literal["RealtimeAgent"] = "RealtimeAgent"
|
|
22
|
+
|
|
23
|
+
def run(self, input_data: Any, **kwargs: Any) -> RealtimeAgentRunResult:
|
|
24
|
+
self.send(input_data)
|
|
25
|
+
events: list[Any] = []
|
|
26
|
+
accumulator = RealtimeTurnAccumulator()
|
|
27
|
+
turn = accumulator.turn
|
|
28
|
+
coordinator = RealtimeToolCoordinator(self.tool_executor, self.toolkit)
|
|
29
|
+
for event in self.stream():
|
|
30
|
+
events.append(event)
|
|
31
|
+
turn = accumulator.consume(event)
|
|
32
|
+
if isinstance(event, ToolCallEvent):
|
|
33
|
+
self.send(coordinator.handle_call(event))
|
|
34
|
+
elif isinstance(event, ToolCancellationEvent):
|
|
35
|
+
coordinator.handle_cancellation(event)
|
|
36
|
+
if self.output_adapter is not None:
|
|
37
|
+
self.output_adapter.handle(event)
|
|
38
|
+
if isinstance(event, TurnCompleteEvent):
|
|
39
|
+
break
|
|
40
|
+
SwarmauriConversationAdapter().append_turn(self.conversation, turn)
|
|
41
|
+
return RealtimeAgentRunResult(turn=turn, events=events)
|
|
42
|
+
|
|
43
|
+
async def arun(
|
|
44
|
+
self,
|
|
45
|
+
input_data: Any,
|
|
46
|
+
**kwargs: Any,
|
|
47
|
+
) -> RealtimeAgentRunResult:
|
|
48
|
+
await self.asend(input_data)
|
|
49
|
+
events: list[Any] = []
|
|
50
|
+
accumulator = RealtimeTurnAccumulator()
|
|
51
|
+
turn = accumulator.turn
|
|
52
|
+
coordinator = RealtimeToolCoordinator(self.tool_executor, self.toolkit)
|
|
53
|
+
async for event in self.astream():
|
|
54
|
+
events.append(event)
|
|
55
|
+
turn = accumulator.consume(event)
|
|
56
|
+
if isinstance(event, ToolCallEvent):
|
|
57
|
+
await self.asend(await coordinator.ahandle_call(event))
|
|
58
|
+
elif isinstance(event, ToolCancellationEvent):
|
|
59
|
+
await coordinator.ahandle_cancellation(event)
|
|
60
|
+
if self.output_adapter is not None:
|
|
61
|
+
await self.output_adapter.ahandle(event)
|
|
62
|
+
if isinstance(event, TurnCompleteEvent):
|
|
63
|
+
break
|
|
64
|
+
SwarmauriConversationAdapter().append_turn(self.conversation, turn)
|
|
65
|
+
return RealtimeAgentRunResult(turn=turn, events=events)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from typing import Any, Literal
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
|
|
5
|
+
from ._internal.RealtimeTurn import RealtimeTurn
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RealtimeAgentRunResult(BaseModel):
|
|
9
|
+
turn: RealtimeTurn
|
|
10
|
+
events: list[Any] = Field(default_factory=list)
|
|
11
|
+
type: Literal["RealtimeAgentRunResult"] = "RealtimeAgentRunResult"
|
|
12
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class LiveSessionEntry:
|
|
8
|
+
conversation_id: str
|
|
9
|
+
creation_task: asyncio.Task[Any]
|
|
10
|
+
session: Any | None = None
|
|
11
|
+
leases: int = 0
|
|
12
|
+
last_used_at: float = field(default=0.0)
|
|
13
|
+
invalidated: bool = False
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from collections.abc import AsyncIterator, Awaitable, Callable
|
|
3
|
+
from contextlib import asynccontextmanager
|
|
4
|
+
from time import monotonic
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from .LiveSessionEntry import LiveSessionEntry
|
|
8
|
+
|
|
9
|
+
SessionFactory = Callable[[], Awaitable[Any]]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class LiveSessionPool:
|
|
13
|
+
"""Lease-based pool with one live session per conversation."""
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self, max_sessions: int = 32, idle_timeout: float = 300.0
|
|
17
|
+
) -> None:
|
|
18
|
+
if max_sessions < 1:
|
|
19
|
+
raise ValueError("max_sessions must be positive")
|
|
20
|
+
self.max_sessions = max_sessions
|
|
21
|
+
self.idle_timeout = idle_timeout
|
|
22
|
+
self._entries: dict[str, LiveSessionEntry] = {}
|
|
23
|
+
self._lock = asyncio.Lock()
|
|
24
|
+
|
|
25
|
+
async def acquire(
|
|
26
|
+
self, conversation_id: str, factory: SessionFactory
|
|
27
|
+
) -> Any:
|
|
28
|
+
close_after: list[Any] = []
|
|
29
|
+
async with self._lock:
|
|
30
|
+
now = monotonic()
|
|
31
|
+
for key, entry in list(self._entries.items()):
|
|
32
|
+
if (
|
|
33
|
+
entry.leases == 0
|
|
34
|
+
and now - entry.last_used_at >= self.idle_timeout
|
|
35
|
+
):
|
|
36
|
+
self._entries.pop(key)
|
|
37
|
+
entry.invalidated = True
|
|
38
|
+
if entry.session is not None:
|
|
39
|
+
close_after.append(entry.session)
|
|
40
|
+
entry = self._entries.get(conversation_id)
|
|
41
|
+
if entry is None:
|
|
42
|
+
idle = sorted(
|
|
43
|
+
(
|
|
44
|
+
item
|
|
45
|
+
for item in self._entries.values()
|
|
46
|
+
if item.leases == 0
|
|
47
|
+
),
|
|
48
|
+
key=lambda item: item.last_used_at,
|
|
49
|
+
)
|
|
50
|
+
while len(self._entries) >= self.max_sessions and idle:
|
|
51
|
+
expired = idle.pop(0)
|
|
52
|
+
self._entries.pop(expired.conversation_id, None)
|
|
53
|
+
expired.invalidated = True
|
|
54
|
+
if expired.session is not None:
|
|
55
|
+
close_after.append(expired.session)
|
|
56
|
+
if len(self._entries) >= self.max_sessions:
|
|
57
|
+
raise RuntimeError(
|
|
58
|
+
"All live sessions are currently leased"
|
|
59
|
+
)
|
|
60
|
+
entry = LiveSessionEntry(
|
|
61
|
+
conversation_id=conversation_id,
|
|
62
|
+
creation_task=asyncio.create_task(factory()),
|
|
63
|
+
last_used_at=now,
|
|
64
|
+
)
|
|
65
|
+
self._entries[conversation_id] = entry
|
|
66
|
+
task = entry.creation_task
|
|
67
|
+
|
|
68
|
+
await asyncio.gather(
|
|
69
|
+
*(session.aclose() for session in close_after),
|
|
70
|
+
return_exceptions=True,
|
|
71
|
+
)
|
|
72
|
+
try:
|
|
73
|
+
session = await task
|
|
74
|
+
except BaseException:
|
|
75
|
+
async with self._lock:
|
|
76
|
+
if self._entries.get(conversation_id) is entry:
|
|
77
|
+
self._entries.pop(conversation_id, None)
|
|
78
|
+
raise
|
|
79
|
+
|
|
80
|
+
invalidated = False
|
|
81
|
+
async with self._lock:
|
|
82
|
+
invalidated = entry.invalidated
|
|
83
|
+
if not invalidated:
|
|
84
|
+
entry.session = session
|
|
85
|
+
entry.leases += 1
|
|
86
|
+
entry.last_used_at = monotonic()
|
|
87
|
+
if invalidated:
|
|
88
|
+
await session.aclose()
|
|
89
|
+
raise RuntimeError("Live session was invalidated during creation")
|
|
90
|
+
return session
|
|
91
|
+
|
|
92
|
+
async def release(
|
|
93
|
+
self, conversation_id: str, *, invalidate: bool = False
|
|
94
|
+
) -> None:
|
|
95
|
+
close_session: Any | None = None
|
|
96
|
+
async with self._lock:
|
|
97
|
+
entry = self._entries.get(conversation_id)
|
|
98
|
+
if entry is None:
|
|
99
|
+
return
|
|
100
|
+
entry.leases = max(0, entry.leases - 1)
|
|
101
|
+
entry.last_used_at = monotonic()
|
|
102
|
+
if invalidate:
|
|
103
|
+
entry.invalidated = True
|
|
104
|
+
if entry.invalidated and entry.leases == 0:
|
|
105
|
+
self._entries.pop(conversation_id, None)
|
|
106
|
+
close_session = entry.session
|
|
107
|
+
if close_session is not None:
|
|
108
|
+
await close_session.aclose()
|
|
109
|
+
|
|
110
|
+
@asynccontextmanager
|
|
111
|
+
async def session(
|
|
112
|
+
self,
|
|
113
|
+
conversation_id: str,
|
|
114
|
+
factory: SessionFactory,
|
|
115
|
+
) -> AsyncIterator[Any]:
|
|
116
|
+
session = await self.acquire(conversation_id, factory)
|
|
117
|
+
invalidate = False
|
|
118
|
+
try:
|
|
119
|
+
yield session
|
|
120
|
+
except BaseException:
|
|
121
|
+
invalidate = True
|
|
122
|
+
raise
|
|
123
|
+
finally:
|
|
124
|
+
await self.release(conversation_id, invalidate=invalidate)
|
|
125
|
+
|
|
126
|
+
async def invalidate(self, conversation_id: str) -> None:
|
|
127
|
+
await self.release(conversation_id, invalidate=True)
|
|
128
|
+
|
|
129
|
+
async def close_all(self) -> None:
|
|
130
|
+
async with self._lock:
|
|
131
|
+
entries = list(self._entries.values())
|
|
132
|
+
self._entries.clear()
|
|
133
|
+
for entry in entries:
|
|
134
|
+
entry.invalidated = True
|
|
135
|
+
for entry in entries:
|
|
136
|
+
if not entry.creation_task.done():
|
|
137
|
+
entry.creation_task.cancel()
|
|
138
|
+
if entry.session is not None:
|
|
139
|
+
await entry.session.aclose()
|
|
140
|
+
|
|
141
|
+
async def size(self) -> int:
|
|
142
|
+
async with self._lock:
|
|
143
|
+
return len(self._entries)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from swarmauri_base.live_models.events.ToolCallEvent import ToolCallEvent
|
|
2
|
+
from swarmauri_base.live_models.events.ToolCancellationEvent import (
|
|
3
|
+
ToolCancellationEvent,
|
|
4
|
+
)
|
|
5
|
+
from swarmauri_base.live_models.inputs.ToolResultInput import ToolResultInput
|
|
6
|
+
from swarmauri_base.tools.ToolExecutorBase import ToolExecutorBase
|
|
7
|
+
from swarmauri_core.toolkits.IToolkit import IToolkit
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class RealtimeToolCoordinator:
|
|
11
|
+
def __init__(
|
|
12
|
+
self, executor: ToolExecutorBase, toolkit: IToolkit | None
|
|
13
|
+
) -> None:
|
|
14
|
+
self.executor = executor
|
|
15
|
+
self.toolkit = toolkit
|
|
16
|
+
|
|
17
|
+
def _tool(self, name: str):
|
|
18
|
+
if self.toolkit is None:
|
|
19
|
+
raise KeyError(f"No toolkit configured for tool {name!r}")
|
|
20
|
+
tool = self.toolkit.get_tool_by_name(name)
|
|
21
|
+
if tool is None:
|
|
22
|
+
raise KeyError(name)
|
|
23
|
+
return tool
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def _input(event: ToolCallEvent, result) -> ToolResultInput:
|
|
27
|
+
correlation_id = event.correlation.get("provider_event_id")
|
|
28
|
+
return ToolResultInput(
|
|
29
|
+
call_id=event.call_id,
|
|
30
|
+
correlation_id=correlation_id,
|
|
31
|
+
payload=result.value
|
|
32
|
+
if not result.error
|
|
33
|
+
else {"error": result.error},
|
|
34
|
+
is_error=bool(result.error),
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def handle_call(self, event: ToolCallEvent) -> ToolResultInput:
|
|
38
|
+
try:
|
|
39
|
+
result = self.executor.execute(
|
|
40
|
+
self._tool(event.tool_name),
|
|
41
|
+
event.arguments,
|
|
42
|
+
call_id=event.call_id,
|
|
43
|
+
context={"correlation": event.correlation},
|
|
44
|
+
)
|
|
45
|
+
except Exception as exc:
|
|
46
|
+
return ToolResultInput(
|
|
47
|
+
call_id=event.call_id,
|
|
48
|
+
correlation_id=event.correlation.get("provider_event_id"),
|
|
49
|
+
payload={"error": str(exc)},
|
|
50
|
+
is_error=True,
|
|
51
|
+
)
|
|
52
|
+
return self._input(event, result)
|
|
53
|
+
|
|
54
|
+
async def ahandle_call(self, event: ToolCallEvent) -> ToolResultInput:
|
|
55
|
+
try:
|
|
56
|
+
result = await self.executor.aexecute(
|
|
57
|
+
self._tool(event.tool_name),
|
|
58
|
+
event.arguments,
|
|
59
|
+
call_id=event.call_id,
|
|
60
|
+
context={"correlation": event.correlation},
|
|
61
|
+
)
|
|
62
|
+
except Exception as exc:
|
|
63
|
+
return ToolResultInput(
|
|
64
|
+
call_id=event.call_id,
|
|
65
|
+
correlation_id=event.correlation.get("provider_event_id"),
|
|
66
|
+
payload={"error": str(exc)},
|
|
67
|
+
is_error=True,
|
|
68
|
+
)
|
|
69
|
+
return self._input(event, result)
|
|
70
|
+
|
|
71
|
+
def handle_cancellation(self, event: ToolCancellationEvent) -> bool:
|
|
72
|
+
return self.executor.cancel(event.call_id)
|
|
73
|
+
|
|
74
|
+
async def ahandle_cancellation(self, event: ToolCancellationEvent) -> bool:
|
|
75
|
+
return await self.executor.acancel(event.call_id)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class RealtimeTurn(BaseModel):
|
|
7
|
+
output_text: str = ""
|
|
8
|
+
input_transcript: str = ""
|
|
9
|
+
output_transcript: str = ""
|
|
10
|
+
audio_chunks: list[bytes] = Field(default_factory=list)
|
|
11
|
+
tool_calls: list[Any] = Field(default_factory=list)
|
|
12
|
+
usage: dict[str, int] = Field(default_factory=dict)
|
|
13
|
+
interrupted: bool = False
|
|
14
|
+
completed: bool = False
|
|
15
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from swarmauri_base.live_models.events.AudioDeltaEvent import AudioDeltaEvent
|
|
2
|
+
from swarmauri_base.live_models.events.InputTranscriptDeltaEvent import (
|
|
3
|
+
InputTranscriptDeltaEvent,
|
|
4
|
+
)
|
|
5
|
+
from swarmauri_base.live_models.events.InterruptionEvent import (
|
|
6
|
+
InterruptionEvent,
|
|
7
|
+
)
|
|
8
|
+
from swarmauri_base.live_models.events.OutputTranscriptDeltaEvent import (
|
|
9
|
+
OutputTranscriptDeltaEvent,
|
|
10
|
+
)
|
|
11
|
+
from swarmauri_base.live_models.events.TextDeltaEvent import TextDeltaEvent
|
|
12
|
+
from swarmauri_base.live_models.events.ToolCallEvent import ToolCallEvent
|
|
13
|
+
from swarmauri_base.live_models.events.TurnCompleteEvent import (
|
|
14
|
+
TurnCompleteEvent,
|
|
15
|
+
)
|
|
16
|
+
from swarmauri_base.live_models.events.UsageEvent import UsageEvent
|
|
17
|
+
|
|
18
|
+
from .RealtimeTurn import RealtimeTurn
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class RealtimeTurnAccumulator:
|
|
22
|
+
def __init__(self) -> None:
|
|
23
|
+
self.turn = RealtimeTurn()
|
|
24
|
+
|
|
25
|
+
def consume(self, event) -> RealtimeTurn:
|
|
26
|
+
if isinstance(event, OutputTranscriptDeltaEvent):
|
|
27
|
+
self.turn.output_transcript += str(event.payload or "")
|
|
28
|
+
elif isinstance(event, InputTranscriptDeltaEvent):
|
|
29
|
+
self.turn.input_transcript += str(event.payload or "")
|
|
30
|
+
elif isinstance(event, TextDeltaEvent):
|
|
31
|
+
self.turn.output_text += str(event.payload or "")
|
|
32
|
+
elif isinstance(event, AudioDeltaEvent):
|
|
33
|
+
self.turn.audio_chunks.append(event.payload)
|
|
34
|
+
elif isinstance(event, ToolCallEvent):
|
|
35
|
+
self.turn.tool_calls.append(event)
|
|
36
|
+
elif isinstance(event, UsageEvent):
|
|
37
|
+
self.turn.usage.update(event.payload)
|
|
38
|
+
elif isinstance(event, InterruptionEvent):
|
|
39
|
+
self.turn.interrupted = True
|
|
40
|
+
elif isinstance(event, TurnCompleteEvent):
|
|
41
|
+
self.turn.completed = True
|
|
42
|
+
return self.turn
|
swarmauri_agent_realtime-0.1.0/swarmauri_agent_realtime/_internal/SwarmauriConversationAdapter.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from swarmauri_base.conversations.ConversationBase import ConversationBase
|
|
2
|
+
from swarmauri_base.messages.MessageBase import MessageBase
|
|
3
|
+
|
|
4
|
+
from .RealtimeTurn import RealtimeTurn
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SwarmauriConversationAdapter:
|
|
8
|
+
def append_turn(
|
|
9
|
+
self,
|
|
10
|
+
conversation: ConversationBase | None,
|
|
11
|
+
turn: RealtimeTurn,
|
|
12
|
+
) -> None:
|
|
13
|
+
if conversation is None:
|
|
14
|
+
return
|
|
15
|
+
content = turn.output_text or turn.output_transcript
|
|
16
|
+
if content:
|
|
17
|
+
conversation.add_message(
|
|
18
|
+
MessageBase(content=content, role="assistant")
|
|
19
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Private realtime-agent orchestration helpers."""
|