pub struct CompletionModel<H = Client> {
pub model: String,
pub strict_tools: bool,
pub tool_result_array_content: bool,
pub intent: CopilotIntent,
/* private fields */
}Fields§
§model: String§strict_tools: bool§tool_result_array_content: bool§intent: CopilotIntentImplementations§
Source§impl<H> CompletionModel<H>where
Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<H> CompletionModel<H>where
Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
pub fn new( client: Client<CopilotExt, H>, model: impl Into<String>, ) -> CompletionModel<H>
pub fn with_strict_tools(self) -> CompletionModel<H>
pub fn with_tool_result_array_content(self) -> CompletionModel<H>
Sourcepub fn with_intent(self, intent: CopilotIntent) -> CompletionModel<H>
pub fn with_intent(self, intent: CopilotIntent) -> CompletionModel<H>
Set the Copilot openai-intent header for completion and streaming requests.
Sourcepub fn with_panel_intent(self) -> CompletionModel<H>
pub fn with_panel_intent(self) -> CompletionModel<H>
Use the generic chat panel openai-intent header for completion and streaming requests.
Sourcepub fn with_edits_intent(self) -> CompletionModel<H>
pub fn with_edits_intent(self) -> CompletionModel<H>
Use the edit-oriented openai-intent header for completion and streaming requests.
Sourcepub async fn raw_completion(
&self,
completion_request: CompletionRequest,
) -> Result<CopilotCompletionResponse, CompletionError>
pub async fn raw_completion( &self, completion_request: CompletionRequest, ) -> Result<CopilotCompletionResponse, CompletionError>
Execute a completion on whichever route this model is configured for and return Copilot’s own wire response.
This is the escape hatch for fields rig does not normalize;
completion::CompletionModel::completion shares the same request,
transport, telemetry and error path.
On the chat route the transport request id (x-request-id) is not on
the wire type and is dropped here; use
Self::raw_completion_with_request_id when the typed route must
reproduce everything completion returns.
Sourcepub async fn raw_completion_with_request_id(
&self,
completion_request: CompletionRequest,
) -> Result<(CopilotCompletionResponse, Option<String>), CompletionError>
pub async fn raw_completion_with_request_id( &self, completion_request: CompletionRequest, ) -> Result<(CopilotCompletionResponse, Option<String>), CompletionError>
Self::raw_completion plus the transport request id from the
x-request-id response header.
The pair exists because the chat route’s wire type
(openai::completion::CompletionResponse) has no slot for a
transport id — it is the shared OpenAI-compatible shape — while the
normalized completion::CompletionResponse carries one. Without this
method, raw_completion(..) followed by
NormalizeCompletionResponse::normalize would silently lack the
provider_request_id that completion::CompletionModel::completion
reports. Reassemble with
with_optional_provider_request_id.
On the responses route the wire type carries the id itself; the pair’s
second element is that same value, so reassembly is a no-op there.
Sourcepub async fn raw_stream(
&self,
completion_request: CompletionRequest,
) -> Result<Pin<Box<dyn Stream<Item = Result<RawStreamingChoice<CopilotStreamingResponse>, CompletionError>> + Send>>, CompletionError>
pub async fn raw_stream( &self, completion_request: CompletionRequest, ) -> Result<Pin<Box<dyn Stream<Item = Result<RawStreamingChoice<CopilotStreamingResponse>, CompletionError>> + Send>>, CompletionError>
Open a stream on whichever route this model is configured for, keeping the terminal record provider-native.
Trait Implementations§
Source§impl<H> Clone for CompletionModel<H>where
H: Clone,
impl<H> Clone for CompletionModel<H>where
H: Clone,
Source§fn clone(&self) -> CompletionModel<H>
fn clone(&self) -> CompletionModel<H>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<H> CompletionModel for CompletionModel<H>where
Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<H> CompletionModel for CompletionModel<H>where
Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
Source§async fn completion(
&self,
completion_request: CompletionRequest,
) -> Result<CompletionResponse, CompletionError>
async fn completion( &self, completion_request: CompletionRequest, ) -> Result<CompletionResponse, CompletionError>
Source§async fn stream(
&self,
completion_request: CompletionRequest,
) -> Result<StreamingCompletionResponse, CompletionError>
async fn stream( &self, completion_request: CompletionRequest, ) -> Result<StreamingCompletionResponse, CompletionError>
Source§fn completion_request(
&self,
prompt: impl Into<Message>,
) -> CompletionRequestBuilder<Self>
fn completion_request( &self, prompt: impl Into<Message>, ) -> CompletionRequestBuilder<Self>
prompt.