pub struct GenericCompletionModel<Ext = OpenAICompletionsExt, H = Client> {
pub model: String,
/* private fields */
}Expand description
A chat-completions model over any OpenAICompatibleProvider extension.
This is the advertised path for OpenAI-compatible providers; see the
provider checklist in crate::providers.
Fields§
§model: StringImplementations§
Source§impl<Ext, H> GenericCompletionModel<Ext, H>
impl<Ext, H> GenericCompletionModel<Ext, H>
pub fn new(client: Client<Ext, H>, model: impl Into<String>) -> Self
Sourcepub fn with_strict_tools(self) -> Self
pub fn with_strict_tools(self) -> Self
Enable strict mode for tool schemas.
When enabled, tool schemas are automatically sanitized to meet OpenAI’s strict mode requirements:
additionalProperties: falseis added to all objects- All properties are marked as required
strict: trueis set on each function definition
This allows OpenAI to guarantee that the model’s tool calls will match the schema exactly.
pub fn with_tool_result_array_content(self) -> Self
Source§impl GenericCompletionModel<OpenAICompletionsExt, Client>
impl GenericCompletionModel<OpenAICompletionsExt, Client>
pub fn into_agent_builder(self) -> AgentBuilder<Self>
Source§impl<H> GenericCompletionModel<OpenRouterExt, H>
impl<H> GenericCompletionModel<OpenRouterExt, H>
Sourcepub fn with_prompt_caching(self) -> Self
pub fn with_prompt_caching(self) -> Self
Enable explicit prompt caching for supported OpenRouter models.
Adds cache_control: {"type": "ephemeral"} to the system-prompt
block so subsequent turns that share the same system prefix can be
billed at the cache-hit rate when the selected model/provider supports
explicit cache breakpoints.
Trait Implementations§
Source§impl<Ext: Clone, H: Clone> Clone for GenericCompletionModel<Ext, H>
impl<Ext: Clone, H: Clone> Clone for GenericCompletionModel<Ext, H>
Source§fn clone(&self) -> GenericCompletionModel<Ext, H>
fn clone(&self) -> GenericCompletionModel<Ext, H>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Ext, H> CompletionModel for GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<Ext, H> CompletionModel for GenericCompletionModel<Ext, H>where
Client<Ext, H>: HttpClientExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
Ext: Provider + OpenAICompatibleProvider + DebugExt + Clone + WasmCompatSend + WasmCompatSync + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
Source§type Response = <Ext as OpenAICompatibleProvider>::Response
type Response = <Ext as OpenAICompatibleProvider>::Response
The raw response type returned by the underlying completion model.
Source§type StreamingResponse = StreamingCompletionResponse<<Ext as OpenAICompatibleProvider>::StreamingUsage>
type StreamingResponse = StreamingCompletionResponse<<Ext as OpenAICompatibleProvider>::StreamingUsage>
The raw response type returned by the underlying completion model when streaming.
Source§fn make(client: &Self::Client, model: impl Into<String>) -> Self
fn make(client: &Self::Client, model: impl Into<String>) -> Self
Construct a model handle from a provider client and model identifier.
Source§fn composes_native_output_with_tools(&self) -> bool
fn composes_native_output_with_tools(&self) -> bool
Whether this provider’s native structured output (
output_schema ->
format/response_format) composes with tool calls in the same
multi-turn request without suppressing them. Read moreSource§async fn completion(
&self,
completion_request: CoreCompletionRequest,
) -> Result<CompletionResponse<Ext::Response>, CompletionError>
async fn completion( &self, completion_request: CoreCompletionRequest, ) -> Result<CompletionResponse<Ext::Response>, CompletionError>
Generates a completion response for the given completion request.
async fn stream( &self, request: CoreCompletionRequest, ) -> Result<StreamingCompletionResponse<Self::StreamingResponse>, CompletionError>
Source§fn completion_request(
&self,
prompt: impl Into<Message>,
) -> CompletionRequestBuilder<Self>
fn completion_request( &self, prompt: impl Into<Message>, ) -> CompletionRequestBuilder<Self>
Generates a completion request builder for the given
prompt.Auto Trait Implementations§
impl<Ext, H> Freeze for GenericCompletionModel<Ext, H>
impl<Ext, H> RefUnwindSafe for GenericCompletionModel<Ext, H>where
H: RefUnwindSafe,
Ext: RefUnwindSafe,
impl<Ext, H> Send for GenericCompletionModel<Ext, H>
impl<Ext, H> Sync for GenericCompletionModel<Ext, H>
impl<Ext, H> Unpin for GenericCompletionModel<Ext, H>
impl<Ext, H> UnsafeUnpin for GenericCompletionModel<Ext, H>where
H: UnsafeUnpin,
Ext: UnsafeUnpin,
impl<Ext, H> UnwindSafe for GenericCompletionModel<Ext, H>where
H: UnwindSafe,
Ext: 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<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
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> 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