Skip to main content

gproxy_protocol/transform/generate/gemini_responses/stream/
mod.rs

1//! Direct, bounded Gemini GenerateContent ↔ Responses incremental conversion.
2//! Native source/target collectors validate lifecycle and final canonical parity.
3//!
4//! Constructors accept an explicit target policy before allocating any IDs.
5//! Gemini response IDs may arrive late: the already emitted Responses ID stays
6//! fixed while its actual source association is attached. A Responses header
7//! requires an observed or explicit actual model and factual creation time;
8//! the client request's routing alias is never used as a model observation.
9//!
10//! Gemini parts become distinct Responses items, including repeated text and
11//! same-name functions. Text, thinking and actual complete function arguments
12//! are emitted immediately. Item status and required usage are finalized only
13//! after native termination and EOF. Gemini usage must be observed at or after
14//! the last content; earlier thinking/candidate components remain lower bounds
15//! until current totals/components or an explicit final thinking fact resolve
16//! the final split. Missing counters are not fabricated as zero.
17//!
18//! Responses message parts retain source order because Gemini has no indexed
19//! text deltas. Later parts/items wait boundedly for earlier content to close;
20//! a complete function argument object may be emitted before output_item.done.
21//! Reasoning content takes precedence over summaries, so summaries wait until
22//! item completion. Final canonical comparison coalesces only adjacent plain
23//! text fragments with the same thought flag; signatures/media/functions stay
24//! exact. Unsigned empty reasoning is omitted like the buffered pair.
25//!
26//! A Responses upstream's reasoning ciphertext cannot become a Gemini
27//! signature, so reasoning replays as unsigned thought text. This pure
28//! converter itself performs no state writes or upstream calls.
29//!
30//! Every failed push poisons the stream. Input/output events and bytes, pending
31//! payloads, items, parts and tools are bounded. Provider errors, premature EOF,
32//! unsupported execution/media and conflicting factual metadata cannot produce
33//! a successful target terminal. Annotations/logprobs/usage retain actual final
34//! native facts rather than replaying previously emitted text.
35
36mod common;
37mod context;
38mod gemini_parts;
39mod gemini_to_responses;
40mod identity;
41mod response_events;
42mod response_items;
43mod response_projection;
44mod responses_to_gemini;
45mod usage;
46pub use common::{StreamEnd, StreamLimits};
47pub use context::{GeminiToResponsesContext, ResponsesToGeminiContext};
48pub use gemini_to_responses::GeminiToResponsesStream;
49pub use responses_to_gemini::ResponsesToGeminiStream;