You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanclass="p">)</span><spanclass="o">-></span><spanclass="n">AsyncGenerator</span><spanclass="p">[</span><spanclass="n">Union</span><spanclass="p">[</span><spanclass="nb">str</span><spanclass="p">,</span><spanclass="nb">bytes</span><spanclass="p">,</span><spanclass="n">BaseModel</span><spanclass="p">],</span><spanclass="kc">None</span><spanclass="p">]:</span><spanclass="c1"># pragma: no cover</span>
<spanclass="p">]:</span><spanclass="c1"># pragma: no cover</span>
169
173
<spanclass="w"></span><spanclass="sd">"""Process a user message (text or audio) and optional images, returning the response stream.</span>
170
174
171
175
<spanclass="sd"> Args:</span>
@@ -179,6 +183,7 @@ <h1>Source code for solana_agent.client.solana_agent</h1><div class="highlight">
179
183
<spanclass="sd"> vad: Whether to use voice activity detection (for audio input)</span>
180
184
<spanclass="sd"> rt_encode_input: Whether to re-encode input audio for compatibility</span>
181
185
<spanclass="sd"> rt_encode_output: Whether to re-encode output audio for compatibility</span>
186
+
<spanclass="sd"> rt_output_modalities: Modalities to return in realtime (default both if None)</span>
182
187
<spanclass="sd"> rt_voice: Voice to use for realtime audio output</span>
183
188
<spanclass="sd"> audio_voice: Voice to use for audio output</span>
Copy file name to clipboardExpand all lines: _sources/index.rst.txt
+104-1Lines changed: 104 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,9 +223,10 @@ This example will work using expo-audio on Android and iOS.
223
223
rt_encode_input=True,
224
224
rt_encode_output=True,
225
225
rt_voice="marin",
226
+
rt_output_modalities=["audio"],
226
227
output_format="audio",
227
-
audio_output_format="mp3",
228
228
audio_input_format="m4a",
229
+
audio_output_format="mp3",
229
230
):
230
231
yield chunk
231
232
@@ -240,6 +241,108 @@ This example will work using expo-audio on Android and iOS.
240
241
},
241
242
)
242
243
244
+
Realtime Text Streaming
245
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246
+
247
+
Due to the overhead of the router (API call) - realtime only supports a single agent setup.
248
+
249
+
Realtime uses MongoDB for memory so Zep is not needed.
250
+
251
+
.. code-block:: python
252
+
253
+
from solana_agent import SolanaAgent
254
+
255
+
solana_agent = SolanaAgent(config=config)
256
+
257
+
asyncdefgenerate():
258
+
asyncfor chunk in solana_agent.process(
259
+
user_id="user123",
260
+
message="What is the latest news on Solana?",
261
+
realtime=True,
262
+
rt_output_modalities=["text"],
263
+
):
264
+
yield chunk
265
+
266
+
Dual Modality Realtime Streaming
267
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268
+
269
+
Solana Agent now supports **dual modality realtime streaming**, allowing you to stream both audio and text simultaneously from a single realtime session. This enables rich conversational experiences where users can receive both voice responses and text transcripts in real-time.
270
+
271
+
Features
272
+
^^^^^^^^
273
+
274
+
- **Simultaneous Audio & Text**: Stream both modalities from the same conversation
275
+
- **Flexible Output**: Choose audio-only, text-only, or both modalities
276
+
- **Real-time Demuxing**: Automatically separate audio and text streams
277
+
- **Mobile Optimized**: Works seamlessly with compressed audio formats (MP4/MP3)
278
+
- **Memory Efficient**: Smart buffering and streaming for optimal performance
279
+
280
+
Mobile App Integration Example
281
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
282
+
283
+
.. code-block:: python
284
+
285
+
from fastapi import UploadFile
286
+
from fastapi.responses import StreamingResponse
287
+
from solana_agent import SolanaAgent
288
+
from solana_agent.interfaces.providers.realtime import RealtimeChunk
0 commit comments