Skip to main content

ArtificialClient

Struct ArtificialClient 

Source
pub struct ArtificialClient<B> { /* private fields */ }
Expand description

A client bound to a single provider.

Clone the client if you need to share it across tasks—B controls whether that’s cheap (e.g. wraps an Arc) or a deep copy.

Implementations§

Source§

impl<B> ArtificialClient<B>

Source

pub fn new(backend: B) -> Self

Create a new client that delegates all calls to backend.

Source

pub fn backend(&self) -> &B

Access the underlying backend (e.g. to tweak provider-specific settings).

Trait Implementations§

Source§

impl<B: ChatCompletionProvider> ChatCompletionProvider for ArtificialClient<B>

Source§

type Message = <B as ChatCompletionProvider>::Message

Chat message type consumed by this backend.
Source§

fn chat_complete<'s, M>( &'s self, params: ChatCompleteParameters<M>, ) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<GenericMessage>>> + Send + 's>>
where M: Into<Self::Message> + Clone + Send + Sync + 's,

Execute the chat prompt and deserialize the provider’s reply into P::Output.
Source§

impl<B: Clone> Clone for ArtificialClient<B>

Source§

fn clone(&self) -> ArtificialClient<B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<B: Debug> Debug for ArtificialClient<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<B: PromptExecutionProvider> PromptExecutionProvider for ArtificialClient<B>

Source§

type Message = <B as PromptExecutionProvider>::Message

Chat message type consumed by this backend. Read more
Source§

fn prompt_execute<'a, 'p, P>( &'a self, prompt: P, ) -> Pin<Box<dyn Future<Output = Result<GenericChatCompletionResponse<P::Output>>> + Send + 'p>>
where P: PromptTemplate + Send + Sync + 'p, <P as IntoPrompt>::Message: Into<Self::Message>, 'a: 'p,

Execute the prompt and deserialize the provider’s reply into P::Output. Read more
Source§

impl<B: StreamingChatProvider> StreamingChatProvider for ArtificialClient<B>

Source§

type Message = <B as StreamingChatProvider>::Message

Chat message type consumed by this backend.
Source§

type Delta<'s> = <B as StreamingChatProvider>::Delta<'s> where Self: 's

The item type returned on the stream. For now it is plain UTF-8 text chunks, but back-ends are free to wrap it in richer enums if needed.
Source§

fn chat_complete_stream<'s, M>( &'s self, params: ChatCompleteParameters<M>, ) -> Self::Delta<'s>
where M: Into<Self::Message> + Clone + Send + Sync + 's,

Start a streaming chat completion.
Source§

impl<B: StreamingEventsProvider> StreamingEventsProvider for ArtificialClient<B>

Source§

type EventStream<'s> = <B as StreamingEventsProvider>::EventStream<'s> where Self: 's

Source§

fn chat_complete_events_stream<'s, M>( &'s self, params: ChatCompleteParameters<M>, ) -> Self::EventStream<'s>
where M: Into<Self::Message> + Clone + Send + Sync + 's,

Source§

impl<B: TranscriptionProvider> TranscriptionProvider for ArtificialClient<B>

Source§

fn transcribe<'s>( &'s self, request: TranscriptionRequest, ) -> Pin<Box<dyn Future<Output = Result<TranscriptionResult>> + Send + 's>>

Auto Trait Implementations§

§

impl<B> Freeze for ArtificialClient<B>

§

impl<B> RefUnwindSafe for ArtificialClient<B>
where B: RefUnwindSafe,

§

impl<B> Send for ArtificialClient<B>
where B: Sync + Send,

§

impl<B> Sync for ArtificialClient<B>
where B: Sync + Send,

§

impl<B> Unpin for ArtificialClient<B>

§

impl<B> UnsafeUnpin for ArtificialClient<B>

§

impl<B> UnwindSafe for ArtificialClient<B>
where B: RefUnwindSafe,

Blanket Implementations§

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<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> 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, 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> 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.