Struct aionic::openai::OpenAIClient

source ·
pub struct OpenAIClient<C: OpenAIConfig> {
    pub client: Client,
    pub api_key: String,
    pub disable_live_stream: bool,
    pub config: C,
}

Fields§

§client: Client§api_key: String§disable_live_stream: bool§config: C

Implementations§

source§

impl OpenAIClient<Image>

source

pub fn set_response_format(self, response_format: &ImageResponseFormat) -> Self

source

pub fn set_max_images(self, number_of_images: u64) -> Self

source

pub fn set_size(self, size: &ImageSize) -> Self

source§

impl OpenAIClient<Image>

source

pub async fn create_image<S: Into<String>>( &mut self, prompt: S ) -> Result<Vec<String>, Box<dyn Error + Send + Sync>>

source

pub async fn edit_image<S: Into<String>>( &mut self, prompt: S, image_file_path: S, mask: Option<S> ) -> Result<Vec<String>, Box<dyn Error + Send + Sync>>

source

pub async fn create_image_variation<S: Into<String>>( &mut self, image_file_path: S ) -> Result<Vec<String>, Box<dyn Error + Send + Sync>>

source§

impl OpenAIClient<Chat>

source

pub fn with_config(self, config: Chat) -> Self

source

pub fn set_model(self, model: String) -> Self

source

pub fn set_max_tokens(self, max_tokens: u64) -> Self

source

pub fn set_messages(self, messages: Vec<Message>) -> Self

source

pub fn set_temperature(self, temperature: f64) -> Self

source

pub fn set_stream_responses(self, streamed: bool) -> Self

source

pub fn set_primer<S: Into<String>>(self, primer_msg: S) -> Self

source

pub fn get_last_message(&self) -> Option<&Message>

source

pub async fn ask<S: Into<String>>( &mut self, prompt: S ) -> Result<String, Box<dyn Error + Send + Sync>>

source

pub async fn chat(&mut self) -> Result<(), Box<dyn Error + Send + Sync>>

source§

impl<C: OpenAIConfig + Serialize + Debug> OpenAIClient<C>

source

pub fn new() -> Self

source

pub fn disable_stdout(self) -> Self

source

pub async fn models( &mut self ) -> Result<Vec<String>, Box<dyn Error + Send + Sync>>

source

pub async fn check_model( &mut self, model: &str ) -> Result<Model, Box<dyn Error + Send + Sync>>

Trait Implementations§

source§

impl<C: Clone + OpenAIConfig> Clone for OpenAIClient<C>

source§

fn clone(&self) -> OpenAIClient<C>

Returns a copy 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<C: Debug + OpenAIConfig> Debug for OpenAIClient<C>

source§

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

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

impl<C: OpenAIConfig + Serialize + Sync + Send + Debug> Default for OpenAIClient<C>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for OpenAIClient<C>

§

impl<C> Send for OpenAIClient<C>

§

impl<C> Sync for OpenAIClient<C>

§

impl<C> Unpin for OpenAIClient<C>where C: Unpin,

§

impl<C> !UnwindSafe for OpenAIClient<C>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for Twhere T: Any,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
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, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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