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
Copy file name to clipboardExpand all lines: documentation/docs/principles.md
+12-7Lines changed: 12 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,8 +34,9 @@ same time, techniques like constrained decoding allow forcing models to produce
34
34
strictly structured, type-safe outputs. In this new landscape, the distinction
35
35
between a schema-less model and a strongly-typed tool is quickly disappearing.
36
36
37
-
<details>
37
+
<detailsmarkdown>
38
38
<summary>The Shift in Practice: Where Rigid APIs Fall Short</summary>
39
+
39
40
Here is how that tension manifests in real-world scenarios:
40
41
41
42
***Models acting as tools:** Can a lightweight model like gemini-flash-lite
@@ -47,8 +48,12 @@ Here is how that tension manifests in real-world scenarios:
47
48
[Nano Banana be plugged as a tool](https://github.com/google-gemini/genai-processors/tree/main/examples/widgets)?
48
49
Can its instructions include images?
49
50
50
-
***Balanced Infrastructure:** Since most users only need a simple "string-in, string-out" API, how do we build a foundation that supports basic users without limiting advanced developers? Can one architecture effectively cater to both?
51
-
</details>
51
+
***Balanced Infrastructure:** Since most users only need a simple "string-in,
52
+
string-out" API, how do we build a foundation that supports basic users
53
+
without limiting advanced developers? Can one architecture effectively cater
54
+
to both?
55
+
56
+
</details>
52
57
53
58
This fragmentation is not inevitable. It is the result of how systems naturally
54
59
evolved along the path of least resistance. We propose an approach based on
@@ -197,7 +202,7 @@ A Processor needs to balance two different needs: it must be easy to call (for
197
202
the user) and easy to implement (for the developer). We achieve this by
198
203
splitting the interface:
199
204
200
-
```
205
+
```python
201
206
classMyProcessor(Processor):
202
207
# The CONSUMER Interface:
203
208
# Designed for the caller. It is permissive with inputs and
@@ -243,7 +248,7 @@ print(
243
248
If we were to expect the answer to actually be a bit longer and were anxious to
244
249
learn the wisdom, we probably would have written
245
250
246
-
```
251
+
```python
247
252
asyncfor part in model('Answer to...'):
248
253
print(part.text, end='')
249
254
```
@@ -252,7 +257,7 @@ To add more functionality while keeping the code structured, processors can be
252
257
chained using `+`. For instance, if the model doesn't have native audio support,
253
258
we can prepend a speech-to-text stage and a microphone input:
254
259
255
-
```
260
+
```python
256
261
from genai_processors.core import audio_io
257
262
from genai_processors.core import speech_to_text
258
263
@@ -263,7 +268,7 @@ And if we need to move beyond linear chains, we can use good old Python control
263
268
flow. For instance, let's squeeze some extra quality by using a critic-reviser
264
269
pattern:
265
270
266
-
```
271
+
```python
267
272
classCriticReviser(processor.Processor):
268
273
"""Agent that uses a critic-reviser loop to improve responses."""
0 commit comments