Skip to content

Commit

Permalink
chore: derive eq on relevant types
Browse files Browse the repository at this point in the history
  • Loading branch information
rellfy committed Aug 27, 2024
1 parent d8f842d commit e6da0a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub type ChatCompletion = ChatCompletionGeneric<ChatCompletionChoice>;
/// A delta chat completion, which is streamed token by token.
pub type ChatCompletionDelta = ChatCompletionGeneric<ChatCompletionChoiceDelta>;

#[derive(Deserialize, Clone, Debug)]
#[derive(Deserialize, Clone, Debug, Eq, PartialEq)]
pub struct ChatCompletionGeneric<C> {
pub id: String,
pub object: String,
Expand All @@ -27,14 +27,14 @@ pub struct ChatCompletionGeneric<C> {
pub usage: Option<Usage>,
}

#[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<String>,
Expand Down Expand Up @@ -77,7 +77,7 @@ pub struct ChatCompletionMessageDelta {
pub function_call: Option<ChatCompletionFunctionCallDelta>,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq)]
pub struct ChatCompletionFunctionDefinition {
/// The name of the function
pub name: String,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub mod moderations;
static API_KEY: Mutex<String> = Mutex::new(String::new());
static BASE_URL: Mutex<String> = Mutex::new(String::new());

#[derive(Deserialize, Debug, Clone)]
#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct OpenAiError {
pub message: String,
#[serde(rename = "type")]
Expand Down Expand Up @@ -51,7 +51,7 @@ pub enum ApiResponse<T> {
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,
Expand Down

0 comments on commit e6da0a4

Please sign in to comment.