Crates.io | mechanise |
lib.rs | mechanise |
version | 0.0.2 |
source | src |
created_at | 2024-03-06 10:39:31.215577 |
updated_at | 2024-03-10 02:29:14.41869 |
description | A, _hopefully_ Rusty wrapper for the Anthropic REST API for Anthropic's `claude` and maybe someday others... Note: This API was in part created with Anthropic's Sonnet model. |
homepage | |
repository | https://github.com/alphastrata/mechanise |
max_upload_size | |
id | 1164631 |
size | 1,108,920 |
Mechanise is a Rust library that provides a simple and intuitive interface for interacting with the Anthropic's messages
REST API.
It exists because getting llms to write an API for themselves has become somewhat of a pastime of mine to evaluate them.
To get started with Mechanise, add it as a dependency to your Rust project's Cargo.toml
file:
[dependencies]
mechanise = "0.1.0"
or, cargo add mechanise
if that's your preferred method of adding dependencies.
After adding Mechanise as a dependency, you will need to obtain an API key to interact with the services.
Make sure to set the ANTHROPIC_API_KEY
environment variable with your API key before running your application.
Then, in your main.rs
:
#[tokio::main]
async fn main() -> Result<(), AnthropicError> {
let client = AnthropicClient::new();
let messages = vec![Message {
role: "user",
content: "Write me a rust function that can generate secure passwords",
}];
let response = client
.create_message("claude-3-opus-20240229", 128, messages)
.await;
match response {
Ok(res) => {
println!("Response: {:?}", res);
}
Err(err) => {
panic!("Error: {}", err);
}
}
Ok(())
}
NOTE:
AnthropicError
will#transparent
most of / all of the errors possible from the dependency crates so be aware of that should you encounter problems.
To run the tests for Mechanise, use the following command:
cargo test
Contributions to Mechanise are welcome! Please feel free to open an issue or submit a pull request if you have improvements or bug fixes.
Mechanise is licensed under the MIT License.
https://crates.io/crates/anthropic https://crates.io/crates/claude_cli