Expand description
Translation between the runtime’s generic chat/tool shape and the Gemini
Code Assist streamGenerateContent wire format (Vertex-style contents +
function calls). Also decodes the SSE line format used by
cloudcode-pa.googleapis.com when called with ?alt=sse.
Structs§
- Gemini
Content - Gemini
Function Call - Gemini
Function Response - Gemini
Generate Request - Envelope matching the Code Assist
streamGenerateContentrequest shape:{ model, project?, user_prompt_id?, request: VertexGenerateContentRequest }. - Gemini
Generate Request Inner - Gemini
Role - Gemini
System Instruction - Gemini
Tool - Gemini
Tool Function Declaration - Gemini
Usage - Provider-reported usage decoded from a stream chunk’s
usageMetadata. Every field is optional: absent upstream counts stay absent. - Tool
Spec
Enums§
- Chat
Turn - Minimal, generic input shape callers assemble before calling the translator. Kept intentionally small: text / tool-call / tool-response only. Media payloads are unsupported in this experimental slice.
- Gemini
Part - Gemini
Role Name - Gemini
Stream Event - A decoded, runtime-facing event from the Gemini stream. Text fragments and tool calls are surfaced separately so the runtime can route them without re-parsing the vendor shape.
Constants§
- MAX_
INBOUND_ LINE_ BYTES - Maximum bytes we will buffer for a single SSE line before failing closed. Google’s Code Assist emits reasonably small JSON chunks; refusing anything bigger prevents a hostile upstream from ballooning memory.
Functions§
- from_
stream_ line - Decode one inbound SSE
data:line into runtime events. Empty/comment lines yield an empty vec;data: [DONE]yieldsFinish { reason: None }. Malformed JSON is surfaced as anErrso the caller can decide whether to terminate the stream (spec: fail closed on structurally invalid frames). - translate_
generate_ content_ request - Translate a normalized conversation + tool set into a
GeminiGenerateRequestready for/v1internal:streamGenerateContent.