Struct ApiInterface

Source
pub struct ApiInterface<'a> {
    pub tokens: u32,
    pub temperature: f32,
    pub context: Vec<String>,
    pub system_prompt: String,
    /* private fields */
}

Fields§

§tokens: u32

Restricts the amount of text returned

§temperature: f32

Influences the predictability/repeatability of the model

§context: Vec<String>

Chat keeps its state here.

§system_prompt: String

The chat model system prompt

Implementations§

Source§

impl<'a> ApiInterface<'_>

Source

pub fn new(api_key: &'a str, tokens: u32, temperature: f32) -> ApiInterface<'a>

Source

pub fn file_info( &self, file_id: String, ) -> Result<ApiResult<String>, Box<dyn Error>>

Get information about a file

Source

pub fn file_contents( &self, file_id: String, ) -> Result<ApiResult<String>, Box<dyn Error>>

Get file cotents

Source

pub fn files_delete( &self, file_id: String, ) -> Result<ApiResult<()>, Box<dyn Error>>

Delete a file

Source

pub fn files_list( &self, ) -> Result<ApiResult<Vec<(String, String)>>, Box<dyn Error>>

Get a list of all files stored on OpenAI

Source

pub fn files_upload_fine_tuning( &self, file: &Path, ) -> Result<ApiResult<String>, Box<dyn Error>>

Upload a file for fine-tuning.

Source

pub fn audio_transcription( &mut self, audio_file: &Path, prompt: Option<&str>, ) -> Result<ApiResult<String>, Box<dyn Error>>

The audio file audio_file is tracscribed. No Usage data returned from this endpoint Get an audio transcription

Source

pub fn fine_tune_create( &self, training_file_id: String, ) -> Result<ApiResult<FineTune>, Box<dyn Error>>

Source

pub fn chat( &mut self, prompt: &str, model: &str, ) -> Result<ApiResult<String>, Box<dyn Error>>

Finetune Workflow:

Documented here

Source

pub fn get_context(&self) -> Result<Vec<String>, Box<dyn Error>>

Read the record of the conversation

Source

pub fn set_context(&mut self, context: Vec<String>)

Restore a record of a conversation

Source

pub fn completion( &mut self, prompt: &str, model: &str, ) -> Result<ApiResult<String>, Box<dyn Error>>

Documented Takes the prompt and sends it to the LLM with no context. The interface has to manage no state

Source

pub fn image( &mut self, prompt: &str, ) -> Result<ApiResult<String>, Box<dyn Error>>

Handle image mode prompts

Source

pub fn image_edit( &mut self, prompt: &str, image: &Path, mask: &Path, ) -> Result<ApiResult<String>, Box<dyn Error>>

Source

pub fn model_list(&self) -> Result<Vec<String>, Box<dyn Error>>

Handle the response if the user queries what models there are (“! md” prompt in cli).

Source

pub fn clear_context(&mut self)

Clear the context used to maintain chat history

Trait Implementations§

Source§

impl<'a> Debug for ApiInterface<'a>

Source§

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

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

impl Display for ApiInterface<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ApiInterface<'a>

§

impl<'a> !RefUnwindSafe for ApiInterface<'a>

§

impl<'a> Send for ApiInterface<'a>

§

impl<'a> Sync for ApiInterface<'a>

§

impl<'a> Unpin for ApiInterface<'a>

§

impl<'a> !UnwindSafe for ApiInterface<'a>

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> 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 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<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> ErasedDestructor for T
where T: 'static,