Skip to main content

causa_protocol/translation/
render_options.rs

1//! Renderer options: the renderer-specific argument each pure renderer takes.
2//!
3//! The renderers in this module tree are pure functions with a fixed argument
4//! list; these values are the one renderer-specific argument they accept. They
5//! live here (translation, transport-free) and are hosted by the matching
6//! gateway configuration in `causa-provider`, which exposes one `with_*`
7//! builder per option next to its existing builders. The configurations keep
8//! `Default`, so the documented defaults hold with no setter call.
9//!
10//! Options are per gateway value, not per request. A host that needs different
11//! behavior for one request holds a second gateway value; the configuration is
12//! cheap to clone and the HTTP client, base URL and media resolver can be
13//! shared, so the cost is one extra value, not a second connection pool.
14
15/// Anthropic Messages render options.
16///
17/// There are none at present. Settings of the `thinking` object, including
18/// `block_binding`, are part of the object the host sends in
19/// `GenerationOptions::extra_body`.
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
21#[non_exhaustive]
22pub struct AnthropicRenderOptions {}
23
24/// OpenAI Responses render options.
25///
26/// `Default` sends `include: ["reasoning.encrypted_content"]` and
27/// `store: false`, as Codex and `pi-ai` do: encrypted reasoning is what makes
28/// a reasoning item replayable under `store: false` or zero data retention.
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30#[non_exhaustive]
31pub struct ResponsesRenderOptions {
32    /// Send `include: ["reasoning.encrypted_content"]` (default `true`).
33    /// Turning it off leaves the field out entirely, so the response carries
34    /// no encrypted reasoning and a reasoning item cannot be meaningfully
35    /// replayed under `store: false`.
36    pub include_encrypted_reasoning: bool,
37    /// Value rendered as `store`; `None` omits the field (default
38    /// `Some(false)`). The host owns the data-retention choice this
39    /// represents.
40    pub store: Option<bool>,
41}
42
43impl Default for ResponsesRenderOptions {
44    fn default() -> Self {
45        Self {
46            include_encrypted_reasoning: true,
47            store: Some(false),
48        }
49    }
50}
51
52/// OpenAI Chat Completions render options.
53///
54/// `Default` replays sealed `reasoning_content`.
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
56#[non_exhaustive]
57pub struct ChatRenderOptions {
58    /// Replay the frame's own-format sealed `reasoning_content` message-level
59    /// items (default `true`). DeepSeek requires `reasoning_content` back on
60    /// every request that carries `tools` and ignores it otherwise; other
61    /// compatible providers differ, which is what this option is for. When it
62    /// is off, the renderer removes the `reasoning_content` key from its own
63    /// sealed items — dropping an item that carries nothing else — and changes
64    /// nothing else. Other sealed message fields still replay.
65    pub replay_reasoning_content: bool,
66}
67
68impl Default for ChatRenderOptions {
69    fn default() -> Self {
70        Self {
71            replay_reasoning_content: true,
72        }
73    }
74}