-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Better Markdown support - Tested tool use with example - Builder pattern for `Requests` - Useful conversion shortcuts - Stream delta enhancements - CI - streaming tool example, how to apply deltas - integrate examples in docs - More conversion shortcuts making example code much shorter - More coverage, even of dumb things like accessor methods. - Verbose Options to print System and Tool use as well as messages. - More Cow<'static, str> to avoid copies and allow `const` `Message`s and so on. Eventually we might add a lifetime generic so this could also be used for zero-copy, deserialization but the cognitive overhead is not worth it yet. - Minor bug fixes.
- Loading branch information
Showing
18 changed files
with
3,303 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# Credit to GitHub Copilot for generating this file | ||
name: Rust CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
components: llvm-tools-preview | ||
|
||
- name: Cache cargo registry | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cargo/registry | ||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-registry- | ||
- name: Cache cargo index | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cargo/git | ||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-index- | ||
- name: Cache cargo build | ||
uses: actions/cache@v2 | ||
with: | ||
path: target | ||
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-build- | ||
- name: Build | ||
run: cargo build --all-features --verbose | ||
|
||
- name: Run tests | ||
run: cargo test --all-features --verbose | ||
|
||
# This should only happen on push to main. PRs should not upload coverage. | ||
- name: Install llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
|
||
- name: Install nextest | ||
uses: taiki-e/install-action@nextest | ||
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
|
||
- name: Write API key to api.key | ||
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
run: echo ${{ secrets.ANTHROPIC_API_KEY }} > api.key | ||
|
||
- name: Collect coverage data (including ignored tests) | ||
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
run: cargo llvm-cov nextest --all-features --run-ignored all --lcov --output-path lcov.info | ||
|
||
- name: Upload coverage to Codecov | ||
if: matrix.os == 'ubuntu-latest' && github.event_name == 'push' | ||
uses: codecov/codecov-action@v2 | ||
with: | ||
files: lcov.info | ||
flags: unittests | ||
name: codecov-umbrella | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
/target | ||
Cargo.lock | ||
.vscode | ||
.vscode | ||
cobertura.xml | ||
api.key | ||
lcov.info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "misanthropic" | ||
version = "0.1.4" | ||
version = "0.2.0" | ||
edition = "2021" | ||
authors = ["Michael de Gans <[email protected]>"] | ||
description = "An async, ergonomic, client for Anthropic's Messages API" | ||
|
@@ -33,11 +33,16 @@ reqwest = { version = "0.12", features = ["json", "stream"] } | |
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
thiserror = "1" | ||
# markdown support | ||
pulldown-cmark = { version = "0.12", optional = true } | ||
pulldown-cmark-to-cmark = { version = "17", optional = true } | ||
static_assertions = "1" | ||
|
||
[dev-dependencies] | ||
clap = { version = "4", features = ["derive"] } | ||
env_logger = "0.11" | ||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] } | ||
itertools = "0.13" | ||
|
||
[features] | ||
# rustls because I am sick of getting Dependabot alerts for OpenSSL. | ||
|
@@ -63,3 +68,12 @@ prompt-caching = ["beta"] | |
log = ["dep:log"] | ||
# Use rustls instead of the system SSL, such as OpenSSL. | ||
rustls-tls = ["reqwest/rustls-tls"] | ||
# Use `pulldown-cmark` for markdown parsing and `pulldown-cmark-to-cmark` for | ||
# converting to CommonMark. | ||
markdown = ["dep:pulldown-cmark", "dep:pulldown-cmark-to-cmark"] | ||
# Derive PartialEq for all structs and enums. | ||
partialeq = [] | ||
|
||
[[example]] | ||
name = "strawberry" | ||
required-features = ["markdown"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.