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="kc">None</span><spanclass="p">]:</span><spanclass="c1"># pragma: no cover</span>
<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>
148
151
<spanclass="w"></span><spanclass="sd">"""Process a user message (text or audio) and optional images, returning the response stream.</span>
149
152
150
153
<spanclass="sd"> Args:</span>
@@ -158,6 +161,7 @@ <h1>Source code for solana_agent.client.solana_agent</h1><div class="highlight">
Copy file name to clipboardExpand all lines: _sources/index.rst.txt
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -234,6 +234,40 @@ Image/Text Streaming
234
234
print(response, end="")
235
235
236
236
237
+
Structured Outputs
238
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239
+
240
+
.. code-block:: python
241
+
242
+
from solana_agent import SolanaAgent
243
+
244
+
config = {
245
+
"openai": {
246
+
"api_key": "your-openai-api-key",
247
+
},
248
+
"agents": [
249
+
{
250
+
"name": "researcher",
251
+
"instructions": "You are a research expert.",
252
+
"specialization": "Researcher",
253
+
}
254
+
],
255
+
}
256
+
257
+
solana_agent = SolanaAgent(config=config)
258
+
259
+
classResearchProposal(BaseModel):
260
+
title: str
261
+
abstract: str
262
+
key_points: list[str]
263
+
264
+
full_response =None
265
+
asyncfor response in solana_agent.process("user123", "Research the life of Ben Franklin - the founding Father.", output_model=ResearchProposal):
266
+
full_response = response
267
+
268
+
print(full_response.model_dump())
269
+
270
+
237
271
Command Line Interface (CLI)
238
272
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239
273
@@ -474,6 +508,8 @@ Guardrails - Optional
474
508
475
509
Guardrails allow you to process and potentially modify user input before it reaches the agent (Input Guardrails) and agent output before it's sent back to the user (Output Guardrails). This is useful for implementing safety checks, content moderation, data sanitization, or custom transformations.
476
510
511
+
Guardrails don't apply to structured outputs.
512
+
477
513
Solana Agent provides a built-in PII scrubber based on scrubadub.
478
514
479
515
.. code-block:: python
@@ -515,6 +551,8 @@ Solana Agent provides a built-in PII scrubber based on scrubadub.
515
551
Example Custom Guardrails - Optional
516
552
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
517
553
554
+
Guardrails don't apply to structured outputs.
555
+
518
556
.. code-block:: python
519
557
520
558
from solana_agent import InputGuardrail, OutputGuardrail
<spanclass="s2">"instructions"</span><spanclass="p">:</span><spanclass="s2">"You are a research expert."</span><spanclass="p">,</span>
<spanclass="k">async</span><spanclass="k">for</span><spanclass="n">response</span><spanclass="ow">in</span><spanclass="n">solana_agent</span><spanclass="o">.</span><spanclass="n">process</span><spanclass="p">(</span><spanclass="s2">"user123"</span><spanclass="p">,</span><spanclass="s2">"Research the life of Ben Franklin - the founding Father."</span><spanclass="p">,</span><spanclass="n">output_model</span><spanclass="o">=</span><spanclass="n">ResearchProposal</span><spanclass="p">):</span>
<h3>Guardrails - Optional<aclass="headerlink" href="#guardrails-optional" title="Link to this heading"></a></h3>
510
542
<p>Guardrails allow you to process and potentially modify user input before it reaches the agent (Input Guardrails) and agent output before it’s sent back to the user (Output Guardrails). This is useful for implementing safety checks, content moderation, data sanitization, or custom transformations.</p>
543
+
<p>Guardrails don’t apply to structured outputs.</p>
511
544
<p>Solana Agent provides a built-in PII scrubber based on scrubadub.</p>
0 commit comments