Skip to main content

CompletionModel

Struct CompletionModel 

Source
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: CopilotIntent

Implementations§

Source§

impl<H> CompletionModel<H>
where Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static, H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,

Source

pub fn new( client: Client<CopilotExt, H>, model: impl Into<String>, ) -> CompletionModel<H>

Source

pub fn with_strict_tools(self) -> CompletionModel<H>

Source

pub fn with_tool_result_array_content(self) -> CompletionModel<H>

Source

pub fn with_intent(self, intent: CopilotIntent) -> CompletionModel<H>

Set the Copilot openai-intent header for completion and streaming requests.

Source

pub fn with_panel_intent(self) -> CompletionModel<H>

Use the generic chat panel openai-intent header for completion and streaming requests.

Source

pub fn with_edits_intent(self) -> CompletionModel<H>

Use the edit-oriented openai-intent header for completion and streaming requests.

Source

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.

Source

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.

Source

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,

Source§

fn clone(&self) -> CompletionModel<H>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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>

Generates a completion response for the given completion request.
Source§

async fn stream( &self, completion_request: CompletionRequest, ) -> Result<StreamingCompletionResponse, CompletionError>

Streams a completion response for the given completion request.
Source§

fn completion_request( &self, prompt: impl Into<Message>, ) -> CompletionRequestBuilder<Self>
where Self: Sized + Clone,

Generates a completion request builder for the given prompt.
Source§

fn capabilities(&self) -> ProviderCapabilities

Provider behavior a runtime should account for when preparing requests. Read more
Source§

impl<H> ConstructCompletionModel<Client<CopilotExt, H>> for CompletionModel<H>
where Client<CopilotExt, H>: HttpClientExt + Clone + Debug + 'static, H: Clone + Default + Debug + WasmCompatSend + WasmCompatSync + 'static,

Source§

fn construct( client: &Client<CopilotExt, H>, model: String, ) -> CompletionModel<H>

Build this model from its provider client and a model identifier.

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<M> AgentModelExt for M
where M: CompletionModel,

Source§

fn into_agent_builder(self) -> AgentBuilder
where Self: 'static,

Convert this model into a classic agent builder.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more