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>, ) -> GenericCompletionModel<Ext, H>
Sourcepub fn with_strict_tools(self) -> GenericCompletionModel<Ext, H>
pub fn with_strict_tools(self) -> GenericCompletionModel<Ext, H>
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) -> GenericCompletionModel<Ext, H>
Source§impl<H> GenericCompletionModel<OpenRouterExt, H>
impl<H> GenericCompletionModel<OpenRouterExt, H>
Sourcepub fn with_prompt_caching(self) -> GenericCompletionModel<OpenRouterExt, H>
pub fn with_prompt_caching(self) -> GenericCompletionModel<OpenRouterExt, H>
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, H> Clone for GenericCompletionModel<Ext, H>
impl<Ext, H> 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: &<GenericCompletionModel<Ext, H> as CompletionModel>::Client,
model: impl Into<String>,
) -> GenericCompletionModel<Ext, H>
fn make( client: &<GenericCompletionModel<Ext, H> as CompletionModel>::Client, model: impl Into<String>, ) -> GenericCompletionModel<Ext, H>
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: CompletionRequest,
) -> Result<CompletionResponse<<Ext as OpenAICompatibleProvider>::Response>, CompletionError>
async fn completion( &self, completion_request: CompletionRequest, ) -> Result<CompletionResponse<<Ext as OpenAICompatibleProvider>::Response>, CompletionError>
Generates a completion response for the given completion request.
async fn stream( &self, request: CompletionRequest, ) -> Result<StreamingCompletionResponse<<GenericCompletionModel<Ext, H> as CompletionModel>::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<M> AgentModelExt for Mwhere
M: CompletionModel,
impl<M> AgentModelExt for Mwhere
M: CompletionModel,
Source§fn into_agent_builder(self) -> AgentBuilder<Self>
fn into_agent_builder(self) -> AgentBuilder<Self>
Convert this model into a classic agent builder.
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