pub struct OpenAiClient {
pub client: Client,
/* private fields */
}
Fields§
§client: Client
Implementations§
Source§impl OpenAiClient
impl OpenAiClient
Source§impl OpenAiClient
impl OpenAiClient
pub fn new(url: &str, authentication: OpenAiAuthentication) -> Self
pub fn with_authentication(self, authentication: OpenAiAuthentication) -> Self
pub fn with_middleware<M: Middleware + 'static>(self, middleware: M) -> Self
Sourcepub fn list_engines(&self) -> ListEnginesRequest<'_>
pub fn list_engines(&self) -> ListEnginesRequest<'_>
Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability.
Sourcepub fn retrieve_engine(&self, engine_id: &str) -> RetrieveEngineRequest<'_>
pub fn retrieve_engine(&self, engine_id: &str) -> RetrieveEngineRequest<'_>
Retrieves a model instance, providing basic information about it such as the owner and availability.
Sourcepub fn create_completion(&self, model: &str) -> CreateCompletionRequest<'_>
pub fn create_completion(&self, model: &str) -> CreateCompletionRequest<'_>
Creates a completion for the provided prompt and parameters
Sourcepub fn create_chat_completion(
&self,
messages: Vec<ChatCompletionRequestMessage>,
model: &str,
) -> CreateChatCompletionRequest<'_>
pub fn create_chat_completion( &self, messages: Vec<ChatCompletionRequestMessage>, model: &str, ) -> CreateChatCompletionRequest<'_>
Creates a completion for the chat message
Sourcepub fn create_edit(
&self,
instruction: &str,
model: &str,
) -> CreateEditRequest<'_>
pub fn create_edit( &self, instruction: &str, model: &str, ) -> CreateEditRequest<'_>
Creates a new edit for the provided input, instruction, and parameters.
Sourcepub fn create_image(&self, prompt: &str) -> CreateImageRequest<'_>
pub fn create_image(&self, prompt: &str) -> CreateImageRequest<'_>
Creates an image given a prompt.
Sourcepub fn create_image_edit(&self) -> CreateImageEditRequest<'_>
pub fn create_image_edit(&self) -> CreateImageEditRequest<'_>
Creates an edited or extended image given an original image and a prompt.
Sourcepub fn create_image_variation(&self) -> CreateImageVariationRequest<'_>
pub fn create_image_variation(&self) -> CreateImageVariationRequest<'_>
Creates a variation of a given image.
Sourcepub fn create_embedding(
&self,
input: Value,
model: &str,
) -> CreateEmbeddingRequest<'_>
pub fn create_embedding( &self, input: Value, model: &str, ) -> CreateEmbeddingRequest<'_>
Creates an embedding vector representing the input text.
Sourcepub fn create_transcription(&self) -> CreateTranscriptionRequest<'_>
pub fn create_transcription(&self) -> CreateTranscriptionRequest<'_>
Transcribes audio into the input language.
Sourcepub fn create_translation(&self) -> CreateTranslationRequest<'_>
pub fn create_translation(&self) -> CreateTranslationRequest<'_>
Translates audio into into English.
Sourcepub fn create_search(
&self,
engine_id: &str,
query: &str,
) -> CreateSearchRequest<'_>
pub fn create_search( &self, engine_id: &str, query: &str, ) -> CreateSearchRequest<'_>
The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them.
To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When file
is set, the search endpoint searches over all the documents in the given file and returns up to the max_rerank
number of documents. These documents will be returned along with their search scores.
The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query.
Sourcepub fn list_files(&self) -> ListFilesRequest<'_>
pub fn list_files(&self) -> ListFilesRequest<'_>
Returns a list of files that belong to the user’s organization.
Sourcepub fn create_file(&self) -> CreateFileRequest<'_>
pub fn create_file(&self) -> CreateFileRequest<'_>
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit.
Sourcepub fn retrieve_file(&self, file_id: &str) -> RetrieveFileRequest<'_>
pub fn retrieve_file(&self, file_id: &str) -> RetrieveFileRequest<'_>
Returns information about a specific file.
Sourcepub fn delete_file(&self, file_id: &str) -> DeleteFileRequest<'_>
pub fn delete_file(&self, file_id: &str) -> DeleteFileRequest<'_>
Delete a file.
Sourcepub fn download_file(&self, file_id: &str) -> DownloadFileRequest<'_>
pub fn download_file(&self, file_id: &str) -> DownloadFileRequest<'_>
Returns the contents of the specified file
Sourcepub fn create_answer(
&self,
args: CreateAnswerRequired<'_>,
) -> CreateAnswerRequest<'_>
pub fn create_answer( &self, args: CreateAnswerRequired<'_>, ) -> CreateAnswerRequest<'_>
Answers the specified question using the provided documents and examples.
The endpoint first searches over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for completion.
Sourcepub fn create_classification(
&self,
model: &str,
query: &str,
) -> CreateClassificationRequest<'_>
pub fn create_classification( &self, model: &str, query: &str, ) -> CreateClassificationRequest<'_>
Classifies the specified query
using provided examples.
The endpoint first searches over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the completions endpoint.
Labeled examples can be provided via an uploaded file
, or explicitly listed in the
request using the examples
parameter for quick tests and small scale use cases.
Sourcepub fn list_fine_tunes(&self) -> ListFineTunesRequest<'_>
pub fn list_fine_tunes(&self) -> ListFineTunesRequest<'_>
List your organization’s fine-tuning jobs
Sourcepub fn create_fine_tune(&self, training_file: &str) -> CreateFineTuneRequest<'_>
pub fn create_fine_tune(&self, training_file: &str) -> CreateFineTuneRequest<'_>
Creates a job that fine-tunes a specified model from a given dataset.
Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
Sourcepub fn retrieve_fine_tune(
&self,
fine_tune_id: &str,
) -> RetrieveFineTuneRequest<'_>
pub fn retrieve_fine_tune( &self, fine_tune_id: &str, ) -> RetrieveFineTuneRequest<'_>
Gets info about the fine-tune job.
Sourcepub fn cancel_fine_tune(&self, fine_tune_id: &str) -> CancelFineTuneRequest<'_>
pub fn cancel_fine_tune(&self, fine_tune_id: &str) -> CancelFineTuneRequest<'_>
Immediately cancel a fine-tune job.
Sourcepub fn list_fine_tune_events(
&self,
fine_tune_id: &str,
) -> ListFineTuneEventsRequest<'_>
pub fn list_fine_tune_events( &self, fine_tune_id: &str, ) -> ListFineTuneEventsRequest<'_>
Get fine-grained status updates for a fine-tune job.
Sourcepub fn list_models(&self) -> ListModelsRequest<'_>
pub fn list_models(&self) -> ListModelsRequest<'_>
Lists the currently available models, and provides basic information about each one such as the owner and availability.
Sourcepub fn retrieve_model(&self, model: &str) -> RetrieveModelRequest<'_>
pub fn retrieve_model(&self, model: &str) -> RetrieveModelRequest<'_>
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
Sourcepub fn delete_model(&self, model: &str) -> DeleteModelRequest<'_>
pub fn delete_model(&self, model: &str) -> DeleteModelRequest<'_>
Delete a fine-tuned model. You must have the Owner role in your organization.
Sourcepub fn create_moderation(&self, input: Value) -> CreateModerationRequest<'_>
pub fn create_moderation(&self, input: Value) -> CreateModerationRequest<'_>
Classifies if text violates OpenAI’s Content Policy