diff --git a/async-openai/Cargo.toml b/async-openai/Cargo.toml index ef63f8a7..17c5549a 100644 --- a/async-openai/Cargo.toml +++ b/async-openai/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "async-openai" -version = "0.18.1" +version = "0.19.0" authors = [ "Himanshu Neema" ] diff --git a/async-openai/src/assistant_files.rs b/async-openai/src/assistant_files.rs index 36a2f909..fbcb35ce 100644 --- a/async-openai/src/assistant_files.rs +++ b/async-openai/src/assistant_files.rs @@ -1,7 +1,6 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{ AssistantFileObject, CreateAssistantFileRequest, DeleteAssistantFileResponse, @@ -11,13 +10,13 @@ use crate::{ }; /// Files attached to an assistant. -pub struct AssistantFiles<'c, C: Config> { - client: &'c Client, +pub struct AssistantFiles<'c> { + client: &'c Client, pub assistant_id: String, } -impl<'c, C: Config> AssistantFiles<'c, C> { - pub fn new(client: &'c Client, assistant_id: &str) -> Self { +impl<'c> AssistantFiles<'c> { + pub fn new(client: &'c Client, assistant_id: &str) -> Self { Self { client, assistant_id: assistant_id.into(), diff --git a/async-openai/src/assistants.rs b/async-openai/src/assistants.rs index 77882fc3..efd71713 100644 --- a/async-openai/src/assistants.rs +++ b/async-openai/src/assistants.rs @@ -1,7 +1,6 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{ AssistantObject, CreateAssistantRequest, DeleteAssistantResponse, ListAssistantsResponse, @@ -13,17 +12,17 @@ use crate::{ /// Build assistants that can call models and use tools to perform tasks. /// /// [Get started with the Assistants API](https://platform.openai.com/docs/assistants) -pub struct Assistants<'c, C: Config> { - client: &'c Client, +pub struct Assistants<'c> { + client: &'c Client, } -impl<'c, C: Config> Assistants<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Assistants<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } /// Assistant [AssistantFiles] API group - pub fn files(&self, assistant_id: &str) -> AssistantFiles { + pub fn files(&self, assistant_id: &str) -> AssistantFiles { AssistantFiles::new(self.client, assistant_id) } diff --git a/async-openai/src/audio.rs b/async-openai/src/audio.rs index 08ea7ac0..cad9cddf 100644 --- a/async-openai/src/audio.rs +++ b/async-openai/src/audio.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{ CreateSpeechRequest, CreateSpeechResponse, CreateTranscriptionRequest, @@ -10,12 +9,12 @@ use crate::{ /// Turn audio into text /// Related guide: [Speech to text](https://platform.openai.com/docs/guides/speech-to-text) -pub struct Audio<'c, C: Config> { - client: &'c Client, +pub struct Audio<'c> { + client: &'c Client, } -impl<'c, C: Config> Audio<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Audio<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/chat.rs b/async-openai/src/chat.rs index c7f9b962..bbcf3f24 100644 --- a/async-openai/src/chat.rs +++ b/async-openai/src/chat.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{ ChatCompletionResponseStream, CreateChatCompletionRequest, CreateChatCompletionResponse, @@ -10,12 +9,12 @@ use crate::{ /// Given a list of messages comprising a conversation, the model will return a response. /// /// Related guide: [Chat completions](https://platform.openai.com//docs/guides/text-generation) -pub struct Chat<'c, C: Config> { - client: &'c Client, +pub struct Chat<'c> { + client: &'c Client, } -impl<'c, C: Config> Chat<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Chat<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/client.rs b/async-openai/src/client.rs index 3e13a91f..45a99fa0 100644 --- a/async-openai/src/client.rs +++ b/async-openai/src/client.rs @@ -1,4 +1,5 @@ use std::pin::Pin; +use std::sync::Arc; use bytes::Bytes; use futures::{stream::StreamExt, Stream}; @@ -18,29 +19,29 @@ use crate::{ #[derive(Debug, Clone)] /// Client is a container for config, backoff and http_client /// used to make API calls. -pub struct Client { +pub struct Client { http_client: reqwest::Client, - config: C, + config: Arc, backoff: backoff::ExponentialBackoff, } -impl Client { +impl Client { /// Client with default [OpenAIConfig] pub fn new() -> Self { Self { http_client: reqwest::Client::new(), - config: OpenAIConfig::default(), + config: Arc::new(OpenAIConfig::default()), backoff: Default::default(), } } } -impl Client { +impl Client { /// Create client with [OpenAIConfig] or [crate::config::AzureConfig] - pub fn with_config(config: C) -> Self { + pub fn with_config(config: C) -> Self { Self { http_client: reqwest::Client::new(), - config, + config: Arc::new(config), backoff: Default::default(), } } @@ -62,80 +63,80 @@ impl Client { // API groups /// To call [Models] group related APIs using this client. - pub fn models(&self) -> Models { + pub fn models(&self) -> Models { Models::new(self) } /// To call [Completions] group related APIs using this client. - pub fn completions(&self) -> Completions { + pub fn completions(&self) -> Completions { Completions::new(self) } /// To call [Chat] group related APIs using this client. - pub fn chat(&self) -> Chat { + pub fn chat(&self) -> Chat { Chat::new(self) } /// To call [Edits] group related APIs using this client. #[deprecated(since = "0.15.0", note = "By OpenAI")] - pub fn edits(&self) -> Edits { + pub fn edits(&self) -> Edits { Edits::new(self) } /// To call [Images] group related APIs using this client. - pub fn images(&self) -> Images { + pub fn images(&self) -> Images { Images::new(self) } /// To call [Moderations] group related APIs using this client. - pub fn moderations(&self) -> Moderations { + pub fn moderations(&self) -> Moderations { Moderations::new(self) } /// To call [Files] group related APIs using this client. - pub fn files(&self) -> Files { + pub fn files(&self) -> Files { Files::new(self) } /// To call [FineTunes] group related APIs using this client. #[deprecated(since = "0.15.0", note = "By OpenAI")] - pub fn fine_tunes(&self) -> FineTunes { + pub fn fine_tunes(&self) -> FineTunes { FineTunes::new(self) } /// To call [FineTuning] group related APIs using this client. - pub fn fine_tuning(&self) -> FineTuning { + pub fn fine_tuning(&self) -> FineTuning { FineTuning::new(self) } /// To call [Embeddings] group related APIs using this client. - pub fn embeddings(&self) -> Embeddings { + pub fn embeddings(&self) -> Embeddings { Embeddings::new(self) } /// To call [Audio] group related APIs using this client. - pub fn audio(&self) -> Audio { + pub fn audio(&self) -> Audio { Audio::new(self) } /// To call [Assistants] group related APIs using this client. - pub fn assistants(&self) -> Assistants { + pub fn assistants(&self) -> Assistants { Assistants::new(self) } /// To call [Threads] group related APIs using this client. - pub fn threads(&self) -> Threads { + pub fn threads(&self) -> Threads { Threads::new(self) } - pub fn config(&self) -> &C { + pub fn config(&self) -> &Arc { &self.config } /// Make a GET request to {path} and deserialize the response body pub(crate) async fn get(&self, path: &str) -> Result - where - O: DeserializeOwned, + where + O: DeserializeOwned, { let request_maker = || async { Ok(self @@ -170,8 +171,8 @@ impl Client { /// Make a DELETE request to {path} and deserialize the response body pub(crate) async fn delete(&self, path: &str) -> Result - where - O: DeserializeOwned, + where + O: DeserializeOwned, { let request_maker = || async { Ok(self @@ -205,9 +206,9 @@ impl Client { /// Make a POST request to {path} and deserialize the response body pub(crate) async fn post(&self, path: &str, request: I) -> Result - where - I: Serialize, - O: DeserializeOwned, + where + I: Serialize, + O: DeserializeOwned, { let request_maker = || async { Ok(self @@ -224,10 +225,10 @@ impl Client { /// POST a form at {path} and deserialize the response body pub(crate) async fn post_form(&self, path: &str, form: F) -> Result - where - O: DeserializeOwned, - reqwest::multipart::Form: async_convert::TryFrom, - F: Clone, + where + O: DeserializeOwned, + reqwest::multipart::Form: async_convert::TryFrom, + F: Clone, { let request_maker = || async { Ok(self @@ -248,9 +249,9 @@ impl Client { /// to retry API call after getting rate limited. request_maker is async because /// reqwest::multipart::Form is created by async calls to read files for uploads. async fn execute_raw(&self, request_maker: M) -> Result - where - M: Fn() -> Fut, - Fut: core::future::Future>, + where + M: Fn() -> Fut, + Fut: core::future::Future>, { let client = self.http_client.clone(); diff --git a/async-openai/src/completion.rs b/async-openai/src/completion.rs index 6e8468fd..791faa92 100644 --- a/async-openai/src/completion.rs +++ b/async-openai/src/completion.rs @@ -1,6 +1,5 @@ use crate::{ client::Client, - config::Config, error::OpenAIError, types::{CompletionResponseStream, CreateCompletionRequest, CreateCompletionResponse}, }; @@ -11,12 +10,13 @@ use crate::{ /// [Learn more](https://platform.openai.com/docs/deprecations/2023-07-06-gpt-and-embeddings) /// /// Related guide: [Legacy Completions](https://platform.openai.com/docs/guides/gpt/completions-api) -pub struct Completions<'c, C: Config> { - client: &'c Client, + +pub struct Completions<'c> { + client: &'c Client, } -impl<'c, C: Config> Completions<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Completions<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/config.rs b/async-openai/src/config.rs index 45d76f00..f2aa48f3 100644 --- a/async-openai/src/config.rs +++ b/async-openai/src/config.rs @@ -1,4 +1,5 @@ //! Client configurations: [OpenAIConfig] for OpenAI, [AzureConfig] for Azure OpenAI Service. +use std::fmt::Debug; use reqwest::header::{HeaderMap, AUTHORIZATION}; use secrecy::{ExposeSecret, Secret}; use serde::Deserialize; @@ -13,7 +14,7 @@ pub const OPENAI_BETA_HEADER: &str = "OpenAI-Beta"; /// [crate::Client] relies on this for every API call on OpenAI /// or Azure OpenAI service -pub trait Config: Clone { +pub trait Config: 'static + Debug + Send + Sync { fn headers(&self) -> HeaderMap; fn url(&self, path: &str) -> String; fn query(&self) -> Vec<(&str, &str)>; diff --git a/async-openai/src/edit.rs b/async-openai/src/edit.rs index daca6b73..78e2349f 100644 --- a/async-openai/src/edit.rs +++ b/async-openai/src/edit.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{CreateEditRequest, CreateEditResponse}, Client, @@ -7,12 +6,12 @@ use crate::{ /// Given a prompt and an instruction, the model will return /// an edited version of the prompt. -pub struct Edits<'c, C: Config> { - client: &'c Client, +pub struct Edits<'c> { + client: &'c Client, } -impl<'c, C: Config> Edits<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Edits<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/embedding.rs b/async-openai/src/embedding.rs index b6a9ab86..3ef3b805 100644 --- a/async-openai/src/embedding.rs +++ b/async-openai/src/embedding.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{CreateEmbeddingRequest, CreateEmbeddingResponse}, Client, @@ -9,12 +8,12 @@ use crate::{ /// consumed by machine learning models and algorithms. /// /// Related guide: [Embeddings](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings) -pub struct Embeddings<'c, C: Config> { - client: &'c Client, +pub struct Embeddings<'c> { + client: &'c Client, } -impl<'c, C: Config> Embeddings<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Embeddings<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/file.rs b/async-openai/src/file.rs index 374ca8db..762a78a4 100644 --- a/async-openai/src/file.rs +++ b/async-openai/src/file.rs @@ -1,19 +1,18 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{CreateFileRequest, DeleteFileResponse, ListFilesResponse, OpenAIFile}, Client, }; -/// Files are used to upload documents that can be used with features like Assistants and Fine-tuning. -pub struct Files<'c, C: Config> { - client: &'c Client, +/// Files are used to upload documents that can be used with features like [Fine-tuning](https://platform.openai.com/docs/api-reference/fine-tunes). +pub struct Files<'c> { + client: &'c Client, } -impl<'c, C: Config> Files<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Files<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/fine_tune.rs b/async-openai/src/fine_tune.rs index 04ce042b..a4a771b9 100644 --- a/async-openai/src/fine_tune.rs +++ b/async-openai/src/fine_tune.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{ CreateFineTuneRequest, FineTune, FineTuneEventsResponseStream, ListFineTuneEventsResponse, @@ -11,12 +10,12 @@ use crate::{ /// Manage fine-tuning jobs to tailor a model to your specific training data. /// /// Related guide: [Fine-tune models](https://platform.openai.com/docs/guides/fine-tuning) -pub struct FineTunes<'c, C: Config> { - client: &'c Client, +pub struct FineTunes<'c> { + client: &'c Client, } -impl<'c, C: Config> FineTunes<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> FineTunes<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/fine_tuning.rs b/async-openai/src/fine_tuning.rs index 08fd3b74..75c44ab1 100644 --- a/async-openai/src/fine_tuning.rs +++ b/async-openai/src/fine_tuning.rs @@ -1,7 +1,6 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{ CreateFineTuningJobRequest, FineTuningJob, ListFineTuningJobEventsResponse, @@ -13,12 +12,12 @@ use crate::{ /// Manage fine-tuning jobs to tailor a model to your specific training data. /// /// Related guide: [Fine-tune models](https://platform.openai.com/docs/guides/fine-tuning) -pub struct FineTuning<'c, C: Config> { - client: &'c Client, +pub struct FineTuning<'c> { + client: &'c Client, } -impl<'c, C: Config> FineTuning<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> FineTuning<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/image.rs b/async-openai/src/image.rs index 98c0c306..94de4936 100644 --- a/async-openai/src/image.rs +++ b/async-openai/src/image.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{ CreateImageEditRequest, CreateImageRequest, CreateImageVariationRequest, ImagesResponse, @@ -10,12 +9,12 @@ use crate::{ /// Given a prompt and/or an input image, the model will generate a new image. /// /// Related guide: [Image generation](https://platform.openai.com/docs/guides/images) -pub struct Images<'c, C: Config> { - client: &'c Client, +pub struct Images<'c> { + client: &'c Client, } -impl<'c, C: Config> Images<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Images<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/message_files.rs b/async-openai/src/message_files.rs index c76c4b30..02658214 100644 --- a/async-openai/src/message_files.rs +++ b/async-openai/src/message_files.rs @@ -1,21 +1,20 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{ListMessageFilesResponse, MessageFileObject}, Client, }; /// Files attached to a message. -pub struct MessageFiles<'c, C: Config> { - client: &'c Client, +pub struct MessageFiles<'c> { + client: &'c Client, pub thread_id: String, pub message_id: String, } -impl<'c, C: Config> MessageFiles<'c, C> { - pub fn new(client: &'c Client, thread_id: &str, message_id: &str) -> Self { +impl<'c> MessageFiles<'c> { + pub fn new(client: &'c Client, thread_id: &str, message_id: &str) -> Self { Self { client, thread_id: thread_id.into(), diff --git a/async-openai/src/messages.rs b/async-openai/src/messages.rs index 1e6bdf41..7ba1876a 100644 --- a/async-openai/src/messages.rs +++ b/async-openai/src/messages.rs @@ -1,21 +1,20 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{CreateMessageRequest, ListMessagesResponse, MessageObject, ModifyMessageRequest}, Client, MessageFiles, }; /// Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). -pub struct Messages<'c, C: Config> { +pub struct Messages<'c> { /// The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) to create a message for. pub thread_id: String, - client: &'c Client, + client: &'c Client, } -impl<'c, C: Config> Messages<'c, C> { - pub fn new(client: &'c Client, thread_id: &str) -> Self { +impl<'c> Messages<'c> { + pub fn new(client: &'c Client, thread_id: &str) -> Self { Self { client, thread_id: thread_id.into(), @@ -23,7 +22,7 @@ impl<'c, C: Config> Messages<'c, C> { } /// Call [MessageFiles] API group - pub fn files(&self, message_id: &str) -> MessageFiles { + pub fn files(&self, message_id: &str) -> MessageFiles { MessageFiles::new(self.client, &self.thread_id, message_id) } diff --git a/async-openai/src/model.rs b/async-openai/src/model.rs index df1a443f..f040b30f 100644 --- a/async-openai/src/model.rs +++ b/async-openai/src/model.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{DeleteModelResponse, ListModelResponse, Model}, Client, @@ -8,12 +7,12 @@ use crate::{ /// List and describe the various models available in the API. /// You can refer to the [Models](https://platform.openai.com/docs/models) documentation to understand what /// models are available and the differences between them. -pub struct Models<'c, C: Config> { - client: &'c Client, +pub struct Models<'c> { + client: &'c Client, } -impl<'c, C: Config> Models<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Models<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/moderation.rs b/async-openai/src/moderation.rs index bcb7da2c..50d3a466 100644 --- a/async-openai/src/moderation.rs +++ b/async-openai/src/moderation.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{CreateModerationRequest, CreateModerationResponse}, Client, @@ -8,12 +7,12 @@ use crate::{ /// Given a input text, outputs if the model classifies it as violating OpenAI's content policy. /// /// Related guide: [Moderations](https://platform.openai.com/docs/guides/moderation) -pub struct Moderations<'c, C: Config> { - client: &'c Client, +pub struct Moderations<'c> { + client: &'c Client, } -impl<'c, C: Config> Moderations<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Moderations<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } diff --git a/async-openai/src/runs.rs b/async-openai/src/runs.rs index 6f2c15a5..b1722121 100644 --- a/async-openai/src/runs.rs +++ b/async-openai/src/runs.rs @@ -1,7 +1,6 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, steps::Steps, types::{ @@ -14,13 +13,13 @@ use crate::{ /// Represents an execution run on a thread. /// /// Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) -pub struct Runs<'c, C: Config> { +pub struct Runs<'c> { pub thread_id: String, - client: &'c Client, + client: &'c Client, } -impl<'c, C: Config> Runs<'c, C> { - pub fn new(client: &'c Client, thread_id: &str) -> Self { +impl<'c> Runs<'c> { + pub fn new(client: &'c Client, thread_id: &str) -> Self { Self { client, thread_id: thread_id.into(), @@ -28,7 +27,7 @@ impl<'c, C: Config> Runs<'c, C> { } /// [Steps] API group - pub fn steps(&self, run_id: &str) -> Steps { + pub fn steps(&self, run_id: &str) -> Steps { Steps::new(self.client, &self.thread_id, run_id) } diff --git a/async-openai/src/steps.rs b/async-openai/src/steps.rs index 595288db..3f98d578 100644 --- a/async-openai/src/steps.rs +++ b/async-openai/src/steps.rs @@ -1,21 +1,20 @@ use serde::Serialize; use crate::{ - config::Config, error::OpenAIError, types::{ListRunStepsResponse, RunStepObject}, Client, }; /// Represents a step in execution of a run. -pub struct Steps<'c, C: Config> { +pub struct Steps<'c> { pub thread_id: String, pub run_id: String, - client: &'c Client, + client: &'c Client, } -impl<'c, C: Config> Steps<'c, C> { - pub fn new(client: &'c Client, thread_id: &str, run_id: &str) -> Self { +impl<'c> Steps<'c> { + pub fn new(client: &'c Client, thread_id: &str, run_id: &str) -> Self { Self { client, thread_id: thread_id.into(), diff --git a/async-openai/src/threads.rs b/async-openai/src/threads.rs index 6025a40f..e564adce 100644 --- a/async-openai/src/threads.rs +++ b/async-openai/src/threads.rs @@ -1,5 +1,4 @@ use crate::{ - config::Config, error::OpenAIError, types::{ CreateThreadAndRunRequest, CreateThreadRequest, DeleteThreadResponse, ModifyThreadRequest, @@ -11,22 +10,22 @@ use crate::{ /// Create threads that assistants can interact with. /// /// Related guide: [Assistants](https://platform.openai.com/docs/assistants/overview) -pub struct Threads<'c, C: Config> { - client: &'c Client, +pub struct Threads<'c> { + client: &'c Client, } -impl<'c, C: Config> Threads<'c, C> { - pub fn new(client: &'c Client) -> Self { +impl<'c> Threads<'c> { + pub fn new(client: &'c Client) -> Self { Self { client } } /// Call [Messages] group API to manage message in [thread_id] thread. - pub fn messages(&self, thread_id: &str) -> Messages { + pub fn messages(&self, thread_id: &str) -> Messages { Messages::new(self.client, thread_id) } /// Call [Runs] group API to manage runs in [thread_id] thread. - pub fn runs(&self, thread_id: &str) -> Runs { + pub fn runs(&self, thread_id: &str) -> Runs { Runs::new(self.client, thread_id) } diff --git a/examples/azure-openai-service/src/main.rs b/examples/azure-openai-service/src/main.rs index c798c865..f9be7665 100644 --- a/examples/azure-openai-service/src/main.rs +++ b/examples/azure-openai-service/src/main.rs @@ -9,7 +9,7 @@ use async_openai::{ Client, }; -async fn chat_completion_example(client: &Client) -> Result<(), Box> { +async fn chat_completion_example(client: &Client) -> Result<(), Box> { let request = CreateChatCompletionRequestArgs::default() .max_tokens(512u16) .model("gpt-3.5-turbo") @@ -60,7 +60,7 @@ async fn chat_completion_example(client: &Client) -> Result<(), Box // Ok(()) // } -async fn embedding_example(client: &Client) -> Result<(), Box> { +async fn embedding_example(client: &Client) -> Result<(), Box> { let request = CreateEmbeddingRequestArgs::default() .model("text-embedding-ada-002") .input("Why do programmers hate nature? It has too many bugs.") diff --git a/examples/fine-tune-cli/src/main.rs b/examples/fine-tune-cli/src/main.rs index cbea1194..5435f035 100644 --- a/examples/fine-tune-cli/src/main.rs +++ b/examples/fine-tune-cli/src/main.rs @@ -8,7 +8,7 @@ use async_openai::{ use clap::{arg, Command}; // TODO: Constructive error handling -async fn data(paths: Vec<&PathBuf>, client: Client) { +async fn data(paths: Vec<&PathBuf>, client: Client) { if paths.len() > 2 { println!("pls provide the trainning file path and optionally a validation file path") } else { @@ -59,7 +59,7 @@ async fn data(paths: Vec<&PathBuf>, client: Client) { } } -async fn retrieve(job_id: String, client: Client) { +async fn retrieve(job_id: String, client: Client) { let ss = client.fine_tunes().retrieve(&job_id).await.unwrap(); if let Some(ft_model) = ss.fine_tuned_model { @@ -69,7 +69,7 @@ async fn retrieve(job_id: String, client: Client) { } } -async fn completion(model: String, prompt: String, client: Client) { +async fn completion(model: String, prompt: String, client: Client) { let request = CreateCompletionRequestArgs::default() .model(model) .prompt(prompt) diff --git a/examples/function-call-stream/src/main.rs b/examples/function-call-stream/src/main.rs index ed46e255..b654b943 100644 --- a/examples/function-call-stream/src/main.rs +++ b/examples/function-call-stream/src/main.rs @@ -82,7 +82,7 @@ async fn main() -> Result<(), Box> { } async fn call_fn( - client: &Client, + client: &Client, name: &str, args: &str, ) -> Result<(), Box> {