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<'_>
impl<'a> ApiInterface<'_>
pub fn new(api_key: &'a str, tokens: u32, temperature: f32) -> ApiInterface<'a>
Sourcepub fn file_info(
&self,
file_id: String,
) -> Result<ApiResult<String>, Box<dyn Error>>
pub fn file_info( &self, file_id: String, ) -> Result<ApiResult<String>, Box<dyn Error>>
Get information about a file
Sourcepub fn file_contents(
&self,
file_id: String,
) -> Result<ApiResult<String>, Box<dyn Error>>
pub fn file_contents( &self, file_id: String, ) -> Result<ApiResult<String>, Box<dyn Error>>
Get file cotents
Sourcepub fn files_delete(
&self,
file_id: String,
) -> Result<ApiResult<()>, Box<dyn Error>>
pub fn files_delete( &self, file_id: String, ) -> Result<ApiResult<()>, Box<dyn Error>>
Delete a file
Sourcepub fn files_list(
&self,
) -> Result<ApiResult<Vec<(String, String)>>, Box<dyn Error>>
pub fn files_list( &self, ) -> Result<ApiResult<Vec<(String, String)>>, Box<dyn Error>>
Get a list of all files stored on OpenAI
Sourcepub fn files_upload_fine_tuning(
&self,
file: &Path,
) -> Result<ApiResult<String>, Box<dyn Error>>
pub fn files_upload_fine_tuning( &self, file: &Path, ) -> Result<ApiResult<String>, Box<dyn Error>>
Upload a file for fine-tuning.
Sourcepub fn audio_transcription(
&mut self,
audio_file: &Path,
prompt: Option<&str>,
) -> Result<ApiResult<String>, Box<dyn Error>>
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
pub fn fine_tune_create( &self, training_file_id: String, ) -> Result<ApiResult<FineTune>, Box<dyn Error>>
Sourcepub fn chat(
&mut self,
prompt: &str,
model: &str,
) -> Result<ApiResult<String>, Box<dyn Error>>
pub fn chat( &mut self, prompt: &str, model: &str, ) -> Result<ApiResult<String>, Box<dyn Error>>
Finetune Workflow:
Documented here
Sourcepub fn get_context(&self) -> Result<Vec<String>, Box<dyn Error>>
pub fn get_context(&self) -> Result<Vec<String>, Box<dyn Error>>
Read the record of the conversation
Sourcepub fn set_context(&mut self, context: Vec<String>)
pub fn set_context(&mut self, context: Vec<String>)
Restore a record of a conversation
Sourcepub fn completion(
&mut self,
prompt: &str,
model: &str,
) -> Result<ApiResult<String>, Box<dyn Error>>
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
Sourcepub fn image(
&mut self,
prompt: &str,
) -> Result<ApiResult<String>, Box<dyn Error>>
pub fn image( &mut self, prompt: &str, ) -> Result<ApiResult<String>, Box<dyn Error>>
Handle image mode prompts
pub fn image_edit( &mut self, prompt: &str, image: &Path, mask: &Path, ) -> Result<ApiResult<String>, Box<dyn Error>>
Sourcepub fn model_list(&self) -> Result<Vec<String>, Box<dyn Error>>
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).
Sourcepub fn clear_context(&mut self)
pub fn clear_context(&mut self)
Clear the context used to maintain chat history
Trait Implementations§
Source§impl<'a> Debug for ApiInterface<'a>
impl<'a> Debug for ApiInterface<'a>
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> 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
Mutably borrows from an owned value. Read more