Skip to content

Commit

Permalink
v0.3.0 Release (#3) - Zero Copy
Browse files Browse the repository at this point in the history
Most of the API is exactly the same, as is usage, with the exception of a few things:

* `Request` has been renamed `Prompt` because in actual use this makes things clearer.
* Almost everything supports zero-copy deserialization where possible at the possible cost of cognitive overhead, however most code will require no changes. Cow strings are used everywhere. This also allows static `Message`s and the like to be created at compile time.
* `Stream` is now `Send`.
* Added an example of an Assistant using Python to solve problems.
* More convenience methods like `to_static` for some structs.
* A few bug fixes
  • Loading branch information
mdegans authored Sep 24, 2024
1 parent aaff3f0 commit 0735915
Show file tree
Hide file tree
Showing 18 changed files with 1,247 additions and 530 deletions.
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "misanthropic"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
authors = ["Michael de Gans <[email protected]>"]
description = "An async, ergonomic, client for Anthropic's Messages API"
Expand Down Expand Up @@ -39,10 +39,15 @@ pulldown-cmark-to-cmark = { version = "17", optional = true }
static_assertions = "1"

[dev-dependencies]
# for all examples
clap = { version = "4", features = ["derive"] }
env_logger = "0.11"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
# for the strawberry example
itertools = "0.13"
# for the python example
subprocess = "0.2"
tempfile = "3.12"

[features]
# rustls because I am sick of getting Dependabot alerts for OpenSSL.
Expand Down Expand Up @@ -77,3 +82,7 @@ partialeq = []
[[example]]
name = "strawberry"
required-features = ["markdown"]

[[example]]
name = "python"
required-features = ["markdown", "prompt-caching"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ println!("{}", message);
- [x] Markdown formatting of messages, including images
- [x] Prompt caching support
- [x] Custom request and endpoint support
- [ ] Zero-copy serde - Coming soon!
- [x] Zero-copy where possible
- [ ] Amazon Bedrock support
- [ ] Vertex AI support

Expand Down
4 changes: 2 additions & 2 deletions examples/neologism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// and `stdin().lock()`. In a real application, these should *usually* be
// replaced with async alternatives.
use clap::Parser;
use misanthropic::{request::message::Role, Client, Request};
use misanthropic::{prompt::message::Role, Client, Prompt};
use std::io::{stdin, BufRead};

/// Invent new words and provide their definitions based on user-provided
Expand Down Expand Up @@ -45,7 +45,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// the box for building `Request`s, such as messages from a list of tuples
// of `Role` and `String`.
let message = client
.message(Request::default().messages([(Role::User, args.prompt)]))
.message(Prompt::default().messages([(Role::User, args.prompt)]))
.await?;

println!("{}", message);
Expand Down
Loading

0 comments on commit 0735915

Please sign in to comment.