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<H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<H> CompletionModel<H>where
Client<H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
pub fn new(client: Client<H>, model: impl Into<String>) -> Self
pub fn with_strict_tools(self) -> Self
pub fn with_tool_result_array_content(self) -> Self
Sourcepub fn with_intent(self, intent: CopilotIntent) -> Self
pub fn with_intent(self, intent: CopilotIntent) -> Self
Set the Copilot openai-intent header for completion and streaming requests.
Sourcepub fn with_panel_intent(self) -> Self
pub fn with_panel_intent(self) -> Self
Use the generic chat panel openai-intent header for completion and streaming requests.
Sourcepub fn with_edits_intent(self) -> Self
pub fn with_edits_intent(self) -> Self
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<RawStreamingResult<CopilotStreamingResponse>, CompletionError>
pub async fn raw_stream( &self, completion_request: CompletionRequest, ) -> Result<RawStreamingResult<CopilotStreamingResponse>, CompletionError>
Open a stream on whichever route this model is configured for, keeping the terminal record provider-native.
Trait Implementations§
Source§impl<H: Clone> Clone for CompletionModel<H>
impl<H: Clone> Clone for CompletionModel<H>
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<H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<H> CompletionModel for CompletionModel<H>where
Client<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.Source§fn capabilities(&self) -> ProviderCapabilities
fn capabilities(&self) -> ProviderCapabilities
Source§impl<H> ConstructCompletionModel<Client<CopilotExt, H>> for CompletionModel<H>where
Client<H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
impl<H> ConstructCompletionModel<Client<CopilotExt, H>> for CompletionModel<H>where
Client<H>: HttpClientExt + Clone + Debug + 'static,
H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,
Auto Trait Implementations§
impl<H = Client> !RefUnwindSafe for CompletionModel<H>
impl<H = Client> !UnwindSafe for CompletionModel<H>
impl<H> Freeze for CompletionModel<H>where
H: Freeze,
impl<H> Send for CompletionModel<H>where
H: Send,
impl<H> Sync for CompletionModel<H>where
H: Sync,
impl<H> Unpin for CompletionModel<H>where
H: Unpin,
impl<H> UnsafeUnpin for CompletionModel<H>where
H: UnsafeUnpin,
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,
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> ⓘ
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