Skip to content

Commit 06399af

Browse files
kiberguscopybara-github
authored andcommitted
Emphasize for coding agents how to call processors in a simpler way.
PiperOrigin-RevId: 881483293
1 parent fe8be44 commit 06399af

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

llms.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The GenAI Processors library provides composable, async building blocks for gene
66
* **Pass inputs directly**: `ProcessorContentTypes` and `ProcessorPartTypes` are wide Unions that accept many existing content types, including plain strings. `ContentStream` automatically coerces them into `ProcessorPart`s, so you do not need to explicitly wrap strings. Processors can injest `ProcessorContentTypes`, `stream_content` is not required. Reference `content_api.py` for full details on what types are accepted.
77
* **Preserve multimodal content**: Do not narrow content to `.text()` needlessly and too early. Models accept multimodal content (images, audio, etc.), so keep it as `ProcessorContentTypes` and only narrow it to text at the last possible moment, if at all needed.
88
* **Safe `.text` access**: Non-text parts throw `ValueError` when accessing `.text`. You can use `content_api.is_text(part.mimetype)` to check if the part is text. But if the code can't handle non text parts properly anyways, just let the exception be risen. The `part.text` is always present and not None, don't use `hasattr` or `is not None` to validate that.
9+
* **Processor Output Gathering**: A processor call `await processor(input_content).gather()` is the best and simplest way to execute a processor and accumulate all outputs into a single `ProcessorContent` object. **DO NOT** use `apply_async` or manual loops to iterate and accumulate parts unless you need to process them sequentially as they arrive.
910
* **CLI Input**: Use `genai_processors.core.text.terminal_input("User: ")` rather than manual `input()` loops; it handles async yielding, `end_of_turn`, and exits implicitly.
1011
* **Conversation Context**: Turn based models require your code to maintain a conversation history. Live models to it for you.
1112

0 commit comments

Comments
 (0)