Skip to content

Commit

Permalink
[fix-readme-example-for-structure-rename] fix readme example for stru…
Browse files Browse the repository at this point in the history
…cture rename
  • Loading branch information
jjjjackson committed Oct 24, 2024
1 parent 42a70b0 commit 8c0f769
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ use clust::messages::Message;
use clust::messages::MessagesRequestBody;
use clust::messages::SystemPrompt;
use clust::messages::StreamOption;
use clust::messages::StreamChunk;
use clust::messages::MessageChunk;
use clust::Client;
use tokio_stream::StreamExt;
Expand Down Expand Up @@ -464,7 +464,7 @@ async fn main() -> anyhow::Result<()> {
| Ok(chunk) => {
println!("Chunk:\n{}", chunk);
match chunk {
| StreamChunk::ContentBlockDelta(content_block_delta) => {
| MessageChunk::ContentBlockDelta(content_block_delta) => {
// Buffer message delta.
buffer.push_str(&content_block_delta.delta.text);
}
Expand Down
30 changes: 29 additions & 1 deletion src/messages/claude_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ pub enum ClaudeModel {
// Claude 3.5 Sonnet
/// Claude 3.5 Sonnet at 2024/06/20
Claude35Sonnet20240620,
// Claude 3.5 Sonnet
/// Claude 3.5 Sonnet at 2024/06/22
Claude35Sonnet20241022,
}

impl Default for ClaudeModel {
Expand All @@ -44,6 +47,9 @@ impl Display for ClaudeModel {
| ClaudeModel::Claude35Sonnet20240620 => {
write!(f, "claude-3-5-sonnet-20240620")
},
| ClaudeModel::Claude35Sonnet20241022 => {
write!(f, "claude-3-5-sonnet-20241022")
},
}
}
}
Expand All @@ -55,6 +61,7 @@ impl ClaudeModel {
| ClaudeModel::Claude3Sonnet20240229 => 4096,
| ClaudeModel::Claude3Haiku20240307 => 4096,
| ClaudeModel::Claude35Sonnet20240620 => 4096,
| ClaudeModel::Claude35Sonnet20241022 => 4096,
}
}
}
Expand All @@ -64,7 +71,8 @@ impl_enum_string_serialization!(
Claude3Opus20240229 => "claude-3-opus-20240229",
Claude3Sonnet20240229 => "claude-3-sonnet-20240229",
Claude3Haiku20240307 => "claude-3-haiku-20240307",
Claude35Sonnet20240620 => "claude-3-5-sonnet-20240620"
Claude35Sonnet20240620 => "claude-3-5-sonnet-20240620",
Claude35Sonnet20241022 => "claude-3-5-sonnet-20241022"
);

#[cfg(test)]
Expand Down Expand Up @@ -97,6 +105,10 @@ mod tests {
ClaudeModel::Claude35Sonnet20240620.to_string(),
"claude-3-5-sonnet-20240620"
);
assert_eq!(
ClaudeModel::Claude3Sonnet20241022.to_string(),
"claude-3-5-sonnet-20241022"
)
}

#[test]
Expand All @@ -117,6 +129,10 @@ mod tests {
ClaudeModel::Claude35Sonnet20240620.max_tokens(),
4096
);
assert_eq!(
ClaudeModel::Claude3Sonnet20241022.max_tokens(),
4096
);
}

#[test]
Expand All @@ -143,6 +159,13 @@ mod tests {
.unwrap(),
ClaudeModel::Claude35Sonnet20240620
);
assert_eq!(
serde_json::from_str::<ClaudeModel>(
"\"claude-3-5-sonnet-20241022\""
)
.unwrap(),
ClaudeModel::Claude3Sonnet20241022
);
}

#[test]
Expand All @@ -164,5 +187,10 @@ mod tests {
.unwrap(),
"\"claude-3-5-sonnet-20240620\""
);
assert_eq!(
serde_json::to_string(&ClaudeModel::Claude3Sonnet20241022)
.unwrap(),
"\"claude-3-5-sonnet-20241022\""
);
}
}

0 comments on commit 8c0f769

Please sign in to comment.