Unverified Commit bce74588 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

chore: Rust to 1.89 and edition 2024 (#2659)

parent 268d017e
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
ChatCompletionResponseStream, CreateChatCompletionRequest, CreateChatCompletionResponse, ChatCompletionResponseStream, CreateChatCompletionRequest, CreateChatCompletionResponse,
}, },
Client,
}; };
/// Given a list of messages comprising a conversation, the model will return a response. /// Given a list of messages comprising a conversation, the model will return a response.
......
...@@ -11,20 +11,20 @@ ...@@ -11,20 +11,20 @@
use std::pin::Pin; use std::pin::Pin;
use bytes::Bytes; use bytes::Bytes;
use futures::{stream::StreamExt, Stream}; use futures::{Stream, stream::StreamExt};
use reqwest::multipart::Form; use reqwest::multipart::Form;
use reqwest_eventsource::{Event, EventSource, RequestBuilderExt}; use reqwest_eventsource::{Event, EventSource, RequestBuilderExt};
use serde::{de::DeserializeOwned, Serialize}; use serde::{Serialize, de::DeserializeOwned};
use crate::{ use crate::{
Assistants, Audio, AuditLogs, Batches, Chat, Completions, Embeddings, FineTuning, Invites,
Models, Projects, Responses, Threads, Uploads, Users, VectorStores,
config::{Config, OpenAIConfig}, config::{Config, OpenAIConfig},
error::{map_deserialization_error, ApiError, OpenAIError, WrappedError}, error::{ApiError, OpenAIError, WrappedError, map_deserialization_error},
file::Files, file::Files,
image::Images, image::Images,
moderation::Moderations, moderation::Moderations,
traits::AsyncTryFrom, traits::AsyncTryFrom,
Assistants, Audio, AuditLogs, Batches, Chat, Completions, Embeddings, FineTuning, Invites,
Models, Projects, Responses, Threads, Uploads, Users, VectorStores,
}; };
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone, Default)]
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
//! Client configurations: [OpenAIConfig] for OpenAI, [AzureConfig] for Azure OpenAI Service. //! Client configurations: [OpenAIConfig] for OpenAI, [AzureConfig] for Azure OpenAI Service.
use reqwest::header::{HeaderMap, AUTHORIZATION}; use reqwest::header::{AUTHORIZATION, HeaderMap};
use secrecy::{ExposeSecret, SecretString}; use secrecy::{ExposeSecret, SecretString};
use serde::Deserialize; use serde::Deserialize;
...@@ -251,10 +251,10 @@ impl Config for AzureConfig { ...@@ -251,10 +251,10 @@ impl Config for AzureConfig {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::Client;
use crate::types::{ use crate::types::{
ChatCompletionRequestMessage, ChatCompletionRequestUserMessage, CreateChatCompletionRequest, ChatCompletionRequestMessage, ChatCompletionRequestUserMessage, CreateChatCompletionRequest,
}; };
use crate::Client;
use std::sync::Arc; use std::sync::Arc;
#[test] #[test]
fn test_client_creation() { fn test_client_creation() {
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use base64::{engine::general_purpose, Engine as _}; use base64::{Engine as _, engine::general_purpose};
use rand::{distr::Alphanumeric, Rng}; use rand::{Rng, distr::Alphanumeric};
use reqwest::Url; use reqwest::Url;
use crate::error::OpenAIError; use crate::error::OpenAIError;
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{CreateBase64EmbeddingResponse, CreateEmbeddingRequest, CreateEmbeddingResponse}, types::{CreateBase64EmbeddingResponse, CreateEmbeddingRequest, CreateEmbeddingResponse},
Client,
}; };
#[cfg(not(feature = "byot"))] #[cfg(not(feature = "byot"))]
......
...@@ -12,10 +12,10 @@ use bytes::Bytes; ...@@ -12,10 +12,10 @@ use bytes::Bytes;
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{CreateFileRequest, DeleteFileResponse, ListFilesResponse, OpenAIFile}, types::{CreateFileRequest, DeleteFileResponse, ListFilesResponse, OpenAIFile},
Client,
}; };
/// Files are used to upload documents that can be used with features like Assistants and Fine-tuning. /// Files are used to upload documents that can be used with features like Assistants and Fine-tuning.
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
CreateFineTuningJobRequest, FineTuningJob, ListFineTuningJobCheckpointsResponse, CreateFineTuningJobRequest, FineTuningJob, ListFineTuningJobCheckpointsResponse,
ListFineTuningJobEventsResponse, ListPaginatedFineTuningJobsResponse, ListFineTuningJobEventsResponse, ListPaginatedFineTuningJobsResponse,
}, },
Client,
}; };
/// Manage fine-tuning jobs to tailor a model to your specific training data. /// Manage fine-tuning jobs to tailor a model to your specific training data.
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
CreateImageEditRequest, CreateImageRequest, CreateImageVariationRequest, ImagesResponse, CreateImageEditRequest, CreateImageRequest, CreateImageVariationRequest, ImagesResponse,
}, },
Client,
}; };
/// Given a prompt and/or an input image, the model will generate a new image. /// Given a prompt and/or an input image, the model will generate a new image.
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{Invite, InviteDeleteResponse, InviteListResponse, InviteRequest}, types::{Invite, InviteDeleteResponse, InviteListResponse, InviteRequest},
Client,
}; };
/// Invite and manage invitations for an organization. Invited users are automatically added to the Default project. /// Invite and manage invitations for an organization. Invited users are automatically added to the Default project.
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
CreateMessageRequest, DeleteMessageResponse, ListMessagesResponse, MessageObject, CreateMessageRequest, DeleteMessageResponse, ListMessagesResponse, MessageObject,
ModifyMessageRequest, ModifyMessageRequest,
}, },
Client,
}; };
/// Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads). /// Represents a message within a [thread](https://platform.openai.com/docs/api-reference/threads).
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{DeleteModelResponse, ListModelResponse, Model}, types::{DeleteModelResponse, ListModelResponse, Model},
Client,
}; };
/// List and describe the various models available in the API. /// List and describe the various models available in the API.
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{CreateModerationRequest, CreateModerationResponse}, types::{CreateModerationRequest, CreateModerationResponse},
Client,
}; };
/// Given text and/or image inputs, classifies if those inputs are potentially harmful across several categories. /// Given text and/or image inputs, classifies if those inputs are potentially harmful across several categories.
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ProjectApiKey, ProjectApiKeyDeleteResponse, ProjectApiKeyListResponse}, types::{ProjectApiKey, ProjectApiKeyDeleteResponse, ProjectApiKeyListResponse},
Client,
}; };
/// Manage API keys for a given project. Supports listing and deleting keys for users. /// Manage API keys for a given project. Supports listing and deleting keys for users.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
...@@ -18,7 +19,6 @@ use crate::{ ...@@ -18,7 +19,6 @@ use crate::{
ProjectServiceAccountCreateResponse, ProjectServiceAccountDeleteResponse, ProjectServiceAccountCreateResponse, ProjectServiceAccountDeleteResponse,
ProjectServiceAccountListResponse, ProjectServiceAccountListResponse,
}, },
Client,
}; };
/// Manage service accounts within a project. A service account is a bot user that is not /// Manage service accounts within a project. A service account is a bot user that is not
......
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
ProjectUser, ProjectUserCreateRequest, ProjectUserDeleteResponse, ProjectUserListResponse, ProjectUser, ProjectUserCreateRequest, ProjectUserDeleteResponse, ProjectUserListResponse,
ProjectUserUpdateRequest, ProjectUserUpdateRequest,
}, },
Client,
}; };
/// Manage users within a project, including adding, updating roles, and removing users. /// Manage users within a project, including adding, updating roles, and removing users.
......
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client, ProjectServiceAccounts, ProjectUsers,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
project_api_keys::ProjectAPIKeys, project_api_keys::ProjectAPIKeys,
types::{Project, ProjectCreateRequest, ProjectListResponse, ProjectUpdateRequest}, types::{Project, ProjectCreateRequest, ProjectListResponse, ProjectUpdateRequest},
Client, ProjectServiceAccounts, ProjectUsers,
}; };
/// Manage the projects within an organization includes creation, updating, and archiving or projects. /// Manage the projects within an organization includes creation, updating, and archiving or projects.
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::responses::{CreateResponse, Response, ResponseStream}, types::responses::{CreateResponse, Response, ResponseStream},
Client,
}; };
/// Given text input or a list of context items, the model will generate a response. /// Given text input or a list of context items, the model will generate a response.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
steps::Steps, steps::Steps,
...@@ -18,7 +19,6 @@ use crate::{ ...@@ -18,7 +19,6 @@ use crate::{
AssistantEventStream, CreateRunRequest, ListRunsResponse, ModifyRunRequest, RunObject, AssistantEventStream, CreateRunRequest, ListRunsResponse, ModifyRunRequest, RunObject,
SubmitToolOutputsRunRequest, SubmitToolOutputsRunRequest,
}, },
Client,
}; };
/// Represents an execution run on a thread. /// Represents an execution run on a thread.
......
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
Client,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ListRunStepsResponse, RunStepObject}, types::{ListRunStepsResponse, RunStepObject},
Client,
}; };
/// Represents a step in execution of a run. /// Represents a step in execution of a run.
......
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
// Licensed under Apache 2.0 // Licensed under Apache 2.0
use crate::{ use crate::{
Client, Messages, Runs,
config::Config, config::Config,
error::OpenAIError, error::OpenAIError,
types::{ types::{
AssistantEventStream, CreateThreadAndRunRequest, CreateThreadRequest, DeleteThreadResponse, AssistantEventStream, CreateThreadAndRunRequest, CreateThreadRequest, DeleteThreadResponse,
ModifyThreadRequest, RunObject, ThreadObject, ModifyThreadRequest, RunObject, ThreadObject,
}, },
Client, Messages, Runs,
}; };
/// Create threads that assistants can interact with. /// Create threads that assistants can interact with.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment