From e6da0a47c4b6696a29e93a5ed99a4decde2056ff Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 27 Aug 2024 23:02:02 +1000 Subject: [PATCH] chore: derive eq on relevant types --- src/chat.rs | 8 ++++---- src/lib.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index 6559e59..715cfef 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -17,7 +17,7 @@ pub type ChatCompletion = ChatCompletionGeneric; /// A delta chat completion, which is streamed token by token. pub type ChatCompletionDelta = ChatCompletionGeneric; -#[derive(Deserialize, Clone, Debug)] +#[derive(Deserialize, Clone, Debug, Eq, PartialEq)] pub struct ChatCompletionGeneric { pub id: String, pub object: String, @@ -27,14 +27,14 @@ pub struct ChatCompletionGeneric { pub usage: Option, } -#[derive(Deserialize, Clone, Debug)] +#[derive(Deserialize, Clone, Debug, Eq, PartialEq)] pub struct ChatCompletionChoice { pub index: u64, pub finish_reason: String, pub message: ChatCompletionMessage, } -#[derive(Deserialize, Clone, Debug)] +#[derive(Deserialize, Clone, Debug, Eq, PartialEq)] pub struct ChatCompletionChoiceDelta { pub index: u64, pub finish_reason: Option, @@ -77,7 +77,7 @@ pub struct ChatCompletionMessageDelta { pub function_call: Option, } -#[derive(Deserialize, Serialize, Debug, Clone)] +#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq)] pub struct ChatCompletionFunctionDefinition { /// The name of the function pub name: String, diff --git a/src/lib.rs b/src/lib.rs index a5e7734..0dda166 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ pub mod moderations; static API_KEY: Mutex = Mutex::new(String::new()); static BASE_URL: Mutex = Mutex::new(String::new()); -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, Eq, PartialEq)] pub struct OpenAiError { pub message: String, #[serde(rename = "type")] @@ -51,7 +51,7 @@ pub enum ApiResponse { Ok(T), } -#[derive(Deserialize, Clone, Copy, Debug)] +#[derive(Deserialize, Clone, Copy, Debug, Eq, PartialEq)] pub struct Usage { pub prompt_tokens: u32, pub completion_tokens: u32,