Skip to main content

ReplayTarget

Trait ReplayTarget 

Source
pub trait ReplayTarget: Debug + WasmCompatSync {
Show 26 methods // Required methods fn api(&self) -> Api; fn provider(&self) -> &str; fn model(&self) -> &str; fn accepts(&self, model: &str) -> Accepts; fn map_options( &self, request: &CompletionRequest, fields: OptionFields<'_>, ) -> OptionMap; // Provided methods fn facts(&self) -> Option<&ModelFacts> { ... } fn encodes(&self, model: &str, media: Media<'_>) -> bool { ... } fn normalize_tool_call_id( &self, id: &str, model: &str, source: Option<&Origin>, ) -> String { ... } fn continues_stored(&self, request: &CompletionRequest) -> bool { ... } fn declares_tools(&self, request: &CompletionRequest) -> bool { ... } fn identity(&self, item: &Value) -> Map<String, Value> { ... } fn call_id_slot(&self) -> Option<&'static str> { ... } fn blob_slots(&self) -> &'static [&'static str] { ... } fn states_finish_reason(&self) -> bool { ... } fn catalog_priced(&self) -> bool { ... } fn binds_context(&self, model: &str) -> bool { ... } fn drops_unbound_items(&self, request: &CompletionRequest) -> bool { ... } fn takes_documents(&self) -> bool { ... } fn needs_next(&self, item: &Value) -> bool { ... } fn hosted_pair(&self, item: &Value) -> Option<(Pairing, String)> { ... } fn starts_with_user(&self) -> bool { ... } fn later_system(&self, model: &str) -> LaterSystem { ... } fn alternates_roles(&self) -> bool { ... } fn hosted_needs_tools(&self) -> bool { ... } fn result_parts(&self, model: &str) -> bool { ... } fn sends_alone(&self, block: &AssistantContent) -> bool { ... }
}
Expand description

The model a request is sent to, as replay sees it. Every completion wire implements it.

Required Methods§

Source

fn api(&self) -> Api

The wire format.

Source

fn provider(&self) -> &str

The provider descriptor name.

Source

fn model(&self) -> &str

The model id the wire addresses.

Source

fn accepts(&self, model: &str) -> Accepts

What model, the model a request addresses on this wire, reads. adapt downgrades everything else, so the encoder never sees it.

Source

fn map_options( &self, request: &CompletionRequest, fields: OptionFields<'_>, ) -> OptionMap

How this wire answers each option of request, whose resolved model and typed fields an answer may depend on. No default: every completion wire writes one, destructuring fields with no .., so a new option fails to compile until the wire answers for it. An unset option answers Mapping::Nothing, so wrap each answer in Mapping::of (Mapping::of_stop for stop), as in seed: Mapping::of(seed, |_| Mapping::unsupported("no such field")); any other answer for an unset option fails every request. Completion::prepare reports each refusal before the wire encodes.

Provided Methods§

Source

fn facts(&self) -> Option<&ModelFacts>

The model facts this wire encodes with: the spec it was connected to and the catalog that answers for other models. None, the default, answers from the built-in catalog.

Source

fn encodes(&self, model: &str, media: Media<'_>) -> bool

Whether the encoder carries media to model: its source (data, URL, file id or string), its media type, and where it sits. adapt replaces every part this refuses with a placeholder, or a text document with its text, so the encoder never refuses canonical content. Row H9 of the history conformance suite holds every wire to it. By default every form is carried.

Source

fn normalize_tool_call_id( &self, id: &str, model: &str, source: Option<&Origin>, ) -> String

The id id takes when a call another model made is sent to model on this wire. source is the call’s origin, None for a hand-built turn. Results answering the call are rewritten to match, and an id another call already took is made distinct.

Source

fn continues_stored(&self, request: &CompletionRequest) -> bool

Whether request continues a conversation the provider stores, such as one naming a previous interaction. Results before the history’s first turn then answer calls the provider holds, so adapt keeps them.

Source

fn declares_tools(&self, request: &CompletionRequest) -> bool

Whether request declares tools to the provider, in tools, in the tools of its additional_params, or through tools the wire adds. A request that declares none gets its history’s calls and results as text. ToolChoice::None still declares them: the wire sends its own none choice beside the tool history.

Source

fn identity(&self, item: &Value) -> Map<String, Value>

The keys of a provider item that survive an edit of its block: an encoder rebuilding the edited block keeps them (Replay::Identity). By default none do.

Source

fn call_id_slot(&self) -> Option<&'static str>

Where a tool call’s id sits in this wire’s call item, as a JSON pointer, when it has one. Replay writes the call’s wire id there, so a replayed item and its result always agree, and a call the provider sent without an id keeps its item only on a wire with a slot.

Source

fn blob_slots(&self) -> &'static [&'static str]

Where this wire’s items keep a reasoning blob (a signature or an encrypted copy of the reasoning), as JSON pointers tried in order. A * step stands for each index of an array. The reply fold records the first that holds one on the block’s Native. By default there are none.

Source

fn states_finish_reason(&self) -> bool

Whether every reply on this wire states why it stopped. A reply that then names no reason failed; a wire with no finish vocabulary, such as a local runtime, says false.

Source

fn catalog_priced(&self) -> bool

Whether the catalog’s per-token API prices apply to this wire’s replies. A subscription backend, or a server that is usually local, says false: its replies then carry only a cost they report.

Source

fn binds_context(&self, model: &str) -> bool

Whether model binds its provider items to the request’s tools and system prompt, so a turn made under another context replays as if from another model.

Source

fn drops_unbound_items(&self, request: &CompletionRequest) -> bool

Whether request asks the provider to drop an item bound to another context itself (Anthropic’s drop_block), so a turn made under another context replays verbatim rather than as another model’s.

Source

fn takes_documents(&self) -> bool

Whether the encoder sends a request’s documents itself. Otherwise they join the history as text before it is adapted.

Source

fn needs_next(&self, item: &Value) -> bool

Whether this provider item requires the item after it in its turn (Responses reasoning): when that one is not replayed, neither is this.

Source

fn hosted_pair(&self, item: &Value) -> Option<(Pairing, String)>

The hosted-tool pair this opaque item belongs to: whether it is the use or the result, and the id they share. A use and its result replay only together, in one turn or across the model’s turns. A use still running when the last turn ended (a paused turn, or one whose client call the hosted tool made) replays alone.

Source

fn starts_with_user(&self) -> bool

Whether the wire rejects a conversation whose first message after the system prompt is not a user message. adapt then drops the assistant turns before the first user message, with their results.

Source

fn later_system(&self, model: &str) -> LaterSystem

Where model takes system messages that come after the conversation begins (LaterSystem). By default where the history has them.

Source

fn alternates_roles(&self) -> bool

Whether the wire requires user and assistant messages to alternate. adapt then joins two messages of one role that only system messages separate, which move after them.

Source

fn hosted_needs_tools(&self) -> bool

Whether a hosted tool’s use and result need the request to declare tools. A request that declares none then sends neither.

Source

fn result_parts(&self, model: &str) -> bool

Whether model reads a tool result as several parts. When it reads neither parts nor result images, adapt joins a result’s text parts into one.

Source

fn sends_alone(&self, block: &AssistantContent) -> bool

Whether block on its own makes an assistant message this wire sends. A turn with no such block carries nothing, so adapt drops it and the user messages around it become one. By default every block does.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ReplayTarget for rig_core::providers::ollama::chat::Chat

Source§

impl ReplayTarget for rig_core::providers::openai::wire::chat::Chat

Source§

impl ReplayTarget for InteractionResume

Source§

impl ReplayTarget for Interactions

Source§

impl ReplayTarget for Messages

Source§

impl ReplayTarget for MockScript

Source§

impl ReplayTarget for NativeChat

Source§

impl ReplayTarget for Responses

Source§

impl<W> ReplayTarget for W
where W: GenerateContentWire,