pub struct CompletionWire { /* private fields */ }Expand description
The completion wire of a local llama.cpp model.
Its payload is the request as Rig prepared it, and its replies are the
inference worker’s Frames.
Trait Implementations§
Source§impl Clone for CompletionWire
impl Clone for CompletionWire
Source§impl Debug for CompletionWire
impl Debug for CompletionWire
impl Eq for CompletionWire
Source§impl PartialEq for CompletionWire
impl PartialEq for CompletionWire
Source§impl ReplayTarget for CompletionWire
impl ReplayTarget for CompletionWire
Source§fn accepts(&self, _model: &str) -> Accepts
fn accepts(&self, _model: &str) -> Accepts
Images reach the model only through a multimodal projector, so a build
without mtmd reads text and tools alone. Assistant images are never
rendered into the prompt.
Source§fn encodes(&self, _model: &str, media: Media<'_>) -> bool
fn encodes(&self, _model: &str, media: Media<'_>) -> bool
Images must carry their bytes: there is no network access to fetch a URL or a provider file id, so those become placeholders instead.
Source§fn states_finish_reason(&self) -> bool
fn states_finish_reason(&self) -> bool
Generation ends at an end-of-generation token or the token budget; neither is reported as a finish reason.
Source§fn later_system(&self, _model: &str) -> LaterSystem
fn later_system(&self, _model: &str) -> LaterSystem
Chat templates commonly accept a system message only at the start.
Source§fn map_options(
&self,
_request: &CompletionRequest,
fields: OptionFields<'_>,
) -> OptionMap
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.Source§fn normalize_tool_call_id(
&self,
id: &str,
model: &str,
source: Option<&Origin>,
) -> String
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
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
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>
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>
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 binds_context(&self, model: &str) -> bool
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
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 route(&self, request: &CompletionRequest) -> Option<&dyn ReplayTarget>
fn route(&self, request: &CompletionRequest) -> Option<&dyn ReplayTarget>
The target
request is sent to, for a wire that picks its API per
request. Preparing the request and folding its reply both read the
target this names, so a turn records the API it was made on. None,
the default, is this target.Source§fn takes_documents(&self) -> bool
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
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)>
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
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 alternates_roles(&self) -> bool
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
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
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
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.impl StructuralPartialEq for CompletionWire
Source§impl Transport<CompletionWire> for Runtime
impl Transport<CompletionWire> for Runtime
Source§fn send(&self, request: CompletionRequest, exchange: Exchange) -> Opening<Frame> ⓘ
fn send(&self, request: CompletionRequest, exchange: Exchange) -> Opening<Frame> ⓘ
Open the reply to one payload. Nothing is sent until the opening is
first polled. A payload the transport cannot send in the exchange’s
mode fails the opening; a failure after the reply opened is its last
frame.
Source§impl Wire for CompletionWire
impl Wire for CompletionWire
Source§type Op = Completion
type Op = Completion
The operation this wire performs.
Source§type Payload = CompletionRequest
type Payload = CompletionRequest
What
Self::encode produces for the transport to send.Source§type Decoder<'id> = FrameDecoder<'id>
type Decoder<'id> = FrameDecoder<'id>
The decoder for one of its replies, branded with that reply.
Source§type Reassembler = RawDocument
type Reassembler = RawDocument
What rebuilds a reply’s provider document from its frames when the
transport reports no whole document, as for a stream. The driver
feeds it every frame and records what it finishes with as
raw.
A wire whose operation’s decoders record raw themselves names
document::Unreassembled; a completion wire cannot, because it
does not Serve completions.Source§fn describe(&self) -> Descriptor<'_>
fn describe(&self) -> Descriptor<'_>
What the wire says about itself.
Source§fn encode(
&self,
request: CompletionRequest,
_mode: Mode,
) -> Result<Self::Payload, EncodeError>
fn encode( &self, request: CompletionRequest, _mode: Mode, ) -> Result<Self::Payload, EncodeError>
The request to send. Pure: it may read
self, request and mode,
and nothing else. A request that cannot be built is an
EncodeError, which always reports as a request failure.Source§fn decoder<'id>(&self) -> FrameDecoder<'id>
fn decoder<'id>(&self) -> FrameDecoder<'id>
A fresh decoder for one reply.
Source§fn reassembler(&self) -> Self::Reassembler
fn reassembler(&self) -> Self::Reassembler
A fresh reassembler for one reply. A wire that picks its API per
reply builds the matching one.
Auto Trait Implementations§
impl Forget for CompletionWire
impl Freeze for CompletionWire
impl Move for CompletionWire
impl RefUnwindSafe for CompletionWire
impl Send for CompletionWirewhere
RawVecInner: Send,
impl Sync for CompletionWirewhere
RawVecInner: Sync,
impl Unpin for CompletionWire
impl UnsafeUnpin for CompletionWire
impl UnwindSafe for CompletionWirewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more