Skip to content

Commit

Permalink
Update clust_tool macro for new tool API
Browse files Browse the repository at this point in the history
  • Loading branch information
mochi-neko committed Apr 13, 2024
1 parent 559a036 commit 35da1f2
Show file tree
Hide file tree
Showing 15 changed files with 1,054 additions and 469 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `clust::messages::StopReason::ToolUse`.
- Add tools for `clust::messages::MessagesRequestBody`.
- Add tool use content block for `clust::messages::Content`.
- Add too result content block for `clust::messages::Content`.

### Removed

Expand Down
2 changes: 2 additions & 0 deletions clust_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ proc-macro = true
quote = "1.0.*"
syn = { version = "2.0.*", features = ["full"] }
proc-macro2 = "1.0.*"
valico = "4.0.*"
serde_json = "1.0.*"

[dev-dependencies]
tokio = { version = "1.37.0", features = ["macros"] }
Expand Down
4 changes: 2 additions & 2 deletions clust_macros/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.76.0"
components = ["rls", "rust-analysis", "rust-src", "rustfmt", "clippy", "cargo-expand"]
channel = "1.77.2"
components = ["rls", "rust-analysis", "rust-src", "rustfmt", "clippy"]
69 changes: 0 additions & 69 deletions clust_macros/src/check_result.rs

This file was deleted.

27 changes: 12 additions & 15 deletions clust_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
use crate::tool::impl_tool;
use proc_macro::TokenStream;

mod check_result;
mod return_type;
mod tool;
mod parameter_type;

/// A procedural macro that generates a `clust::messages::Tool` or `clust::messages::AsyncTool`
/// implementation for the annotated function with documentation.
Expand Down Expand Up @@ -56,9 +57,7 @@ mod tool;
///
/// ```rust
/// use clust_macros::clust_tool;
/// use std::collections::BTreeMap;
/// use std::iter::FromIterator;
/// use clust::messages::{FunctionCalls, Invoke, Tool};
/// use clust::messages::{ToolUse, Tool};
///
/// /// Increments the argument by 1.
/// ///
Expand All @@ -73,17 +72,15 @@ mod tool;
///
/// let description = tool.description();
///
/// let function_calls = FunctionCalls {
/// invoke: Invoke {
/// tool_name: String::from("incrementer"),
/// parameters: BTreeMap::from_iter(vec![(
/// "value".to_string(),
/// "42".to_string(),
/// )]),
/// },
/// };
///
/// let result = tool.call(function_calls).unwrap();
/// let tool_use = ToolUse::new(
/// "toolu_XXXX",
/// "incrementer",
/// serde_json::json!({
/// "value": 42
/// }),
/// );
///
/// let result = tool.call(tool_use).unwrap();
/// ```
///
/// Generated XML tool description from above implementation is as follows:
Expand Down
Loading

0 comments on commit 35da1f2

Please sign in to comment.