pub struct NativeChat {
pub provider: CohereConfig,
pub model: String,
pub strict_tools: bool,
}Expand description
The native chat wire: a provider configuration, a model, and the per-turn options the endpoint takes.
Fields§
§provider: CohereConfigWhich provider, and how to reach it.
model: StringThe model this wire addresses.
strict_tools: boolWhether requests ask Cohere to hold tool calls to their schemas
(strict_tools).
Implementations§
Source§impl NativeChat
impl NativeChat
Sourcepub fn new(provider: CohereConfig, model: impl Into<String>) -> Self
pub fn new(provider: CohereConfig, model: impl Into<String>) -> Self
The wire for model on provider, with every option off.
Sourcepub fn with_strict_tools(self) -> Self
pub fn with_strict_tools(self) -> Self
Ask Cohere to hold every tool call to its tool’s schema.
Trait Implementations§
Source§impl Clone for NativeChat
impl Clone for NativeChat
Source§impl Debug for NativeChat
impl Debug for NativeChat
Source§impl<'de> Deserialize<'de> for NativeChat
impl<'de> Deserialize<'de> for NativeChat
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for NativeChat
impl PartialEq for NativeChat
Source§impl ReplayTarget for NativeChat
impl ReplayTarget for NativeChat
Source§fn map_options(
&self,
request: &CompletionRequest,
fields: OptionFields<'_>,
) -> OptionMap
fn map_options( &self, request: &CompletionRequest, fields: OptionFields<'_>, ) -> OptionMap
Section 6.5 of the typed-options design, for the native API.
Source§fn accepts(&self, model: &str) -> Accepts
fn accepts(&self, model: &str) -> Accepts
Cohere’s vision models read user images; no model reads images in assistant turns or tool results.
Source§fn encodes(&self, _model: &str, media: Media<'_>) -> bool
fn encodes(&self, _model: &str, media: Media<'_>) -> bool
The encoder carries a user image by URL or typed data, and a text document as its text. It carries no other media.
Source§fn identity(&self, item: &Value) -> Map<String, Value>
fn identity(&self, item: &Value) -> Map<String, Value>
An edited block keeps its kind: a tool plan stays a plan.
Source§fn sends_alone(&self, block: &AssistantContent) -> bool
fn sends_alone(&self, block: &AssistantContent) -> bool
Text and thinking with text are content parts, an opaque item with
a type is a part, and a call is a call. A tool plan rides with its
calls, and images are never sent.
Source§fn call_id_slot(&self) -> Option<&'static str>
fn call_id_slot(&self) -> Option<&'static str>
Source§fn takes_documents(&self) -> bool
fn takes_documents(&self) -> bool
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
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
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
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 states_finish_reason(&self) -> bool
fn states_finish_reason(&self) -> bool
supportsFinishReason); a wire
with no finish vocabulary, such as a local runtime, says false.Source§fn binds_context(&self, model: &str) -> bool
fn binds_context(&self, model: &str) -> bool
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
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>
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 needs_next(&self, item: &Value) -> bool
fn needs_next(&self, item: &Value) -> bool
Source§fn hosted_pair(&self, item: &Value) -> Option<(Pairing, String)>
fn hosted_pair(&self, item: &Value) -> Option<(Pairing, String)>
Source§fn starts_with_user(&self) -> bool
fn starts_with_user(&self) -> bool
adapt then drops the
assistant turns before the first user message, with their results.Source§fn later_system(&self, model: &str) -> LaterSystem
fn later_system(&self, model: &str) -> LaterSystem
model takes system messages that come after the
conversation begins (LaterSystem). By default where the history
has them.Source§fn alternates_roles(&self) -> bool
fn alternates_roles(&self) -> bool
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
Source§impl Serialize for NativeChat
impl Serialize for NativeChat
impl StructuralPartialEq for NativeChat
Source§impl Wire for NativeChat
impl Wire for NativeChat
Source§type Op = Completion
type Op = Completion
Source§type Payload = Encoded
type Payload = Encoded
Self::encode produces for the transport to send.Source§type Decoder<'id> = ChatDecoder
type Decoder<'id> = ChatDecoder
Source§type Reassembler = ChatResponse
type Reassembler = ChatResponse
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<'_>
Source§fn encode(
&self,
request: CompletionRequest,
mode: Mode,
) -> Result<Encoded, EncodeError>
fn encode( &self, request: CompletionRequest, mode: Mode, ) -> Result<Encoded, EncodeError>
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 reassembler(&self) -> Self::Reassembler
fn reassembler(&self) -> Self::Reassembler
Auto Trait Implementations§
impl Freeze for NativeChat
impl RefUnwindSafe for NativeChat
impl Send for NativeChat
impl Sync for NativeChat
impl Unpin for NativeChat
impl UnsafeUnpin for NativeChat
impl UnwindSafe for NativeChat
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
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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