Skip to content

Commit

Permalink
Add Haiku model and update version v0.2.0 -> v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mochi-neko committed Mar 14, 2024
1 parent 5625548 commit 9cb527f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add the `Claude 3 Haiku` model.
- Support `tokio::stream` for streaming API by optional.

## [0.3.0] - 2024-03-14

### Added

- Add the Claude 3 Haiku model: `claude-3-haiku-20240307`.

## [0.2.0] - 2024-03-13

Expand All @@ -27,7 +33,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add the `Create a Message` API.

[unreleased]: https://github.com/mochi-neko/clust/compare/v0.2.0...HEAD
[unreleased]: https://github.com/mochi-neko/clust/compare/v0.3.0...HEAD

[0.3.0]: https://github.com/mochi-neko/clust/compare/v0.2.0...v0.3.0

[0.2.0]: https://github.com/mochi-neko/clust/compare/v0.1.0...v0.2.0

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clust"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["Mochineko <[email protected]>"]
rust-version = "1.76"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ or add the following line to your Cargo.toml:

```toml
[dependencies]
clust = "0.2.0"
clust = "0.3.0"
```

## Supported APIs
Expand Down
2 changes: 1 addition & 1 deletion examples/create_a_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn main() -> anyhow::Result<()> {
let client = Client::from_env()?;

// 2. Create a request body.
let model = ClaudeModel::Claude3Sonnet20240229;
let model = ClaudeModel::Claude3Haiku20240307;
let messages = vec![Message::user(
arguments.message,
)];
Expand Down
27 changes: 25 additions & 2 deletions src/messages/claude_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ pub enum ClaudeModel {
/// Claude 3 Sonnet at 2024/02/29.
Claude3Sonnet20240229,
// Claude 3 Haiku
// Coming soon
/// Claude 3 Haiku at 2024/03/07.
Claude3Haiku20240307,
}

impl Default for ClaudeModel {
Expand All @@ -34,6 +35,9 @@ impl Display for ClaudeModel {
| ClaudeModel::Claude3Sonnet20240229 => {
write!(f, "claude-3-sonnet-20240229")
},
| ClaudeModel::Claude3Haiku20240307 => {
write!(f, "claude-3-haiku-20240307")
},
}
}
}
Expand All @@ -43,14 +47,16 @@ impl ClaudeModel {
match self {
| ClaudeModel::Claude3Opus20240229 => 4096,
| ClaudeModel::Claude3Sonnet20240229 => 4096,
| ClaudeModel::Claude3Haiku20240307 => 4096,
}
}
}

impl_enum_string_serialization!(
ClaudeModel,
Claude3Opus20240229 => "claude-3-opus-20240229",
Claude3Sonnet20240229 => "claude-3-sonnet-20240229"
Claude3Sonnet20240229 => "claude-3-sonnet-20240229",
Claude3Haiku20240307 => "claude-3-haiku-20240307"
);

#[cfg(test)]
Expand All @@ -75,6 +81,10 @@ mod tests {
ClaudeModel::Claude3Sonnet20240229.to_string(),
"claude-3-sonnet-20240229"
);
assert_eq!(
ClaudeModel::Claude3Haiku20240307.to_string(),
"claude-3-haiku-20240307"
);
}

#[test]
Expand All @@ -87,6 +97,10 @@ mod tests {
ClaudeModel::Claude3Sonnet20240229.max_tokens(),
4096
);
assert_eq!(
ClaudeModel::Claude3Haiku20240307.max_tokens(),
4096
);
}

#[test]
Expand All @@ -101,6 +115,11 @@ mod tests {
.unwrap(),
ClaudeModel::Claude3Sonnet20240229
);
assert_eq!(
serde_json::from_str::<ClaudeModel>("\"claude-3-haiku-20240307\"")
.unwrap(),
ClaudeModel::Claude3Haiku20240307
);
}

#[test]
Expand All @@ -113,5 +132,9 @@ mod tests {
serde_json::to_string(&ClaudeModel::Claude3Sonnet20240229).unwrap(),
"\"claude-3-sonnet-20240229\""
);
assert_eq!(
serde_json::to_string(&ClaudeModel::Claude3Haiku20240307).unwrap(),
"\"claude-3-haiku-20240307\""
);
}
}

0 comments on commit 9cb527f

Please sign in to comment.