File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " misanthropic"
3
- version = " 0.3.2 "
3
+ version = " 0.3.3 "
4
4
edition = " 2021"
5
5
authors = [
" Michael de Gans <[email protected] >" ]
6
6
description = " An async, ergonomic, client for Anthropic's Messages API"
Original file line number Diff line number Diff line change @@ -255,6 +255,20 @@ impl<'a> Tool<'a> {
255
255
pub fn is_cached ( & self ) -> bool {
256
256
self . cache_control . is_some ( )
257
257
}
258
+
259
+ /// Try to convert from a serializable value to a [`Tool`].
260
+ // A blanket impl for TryFrom<T> where T: Serialize would be nice but it
261
+ // would conflict with the blanket impl for TryFrom<Value> where Value:
262
+ // Serialize. This is a bit of a hack but it works.
263
+ pub fn from_serializable < T > (
264
+ value : T ,
265
+ ) -> std:: result:: Result < Self , serde_json:: Error >
266
+ where
267
+ T : Serialize ,
268
+ {
269
+ let value = serde_json:: to_value ( value) ?;
270
+ value. try_into ( )
271
+ }
258
272
}
259
273
260
274
impl TryFrom < serde_json:: Value > for Tool < ' _ > {
You can’t perform that action at this time.
0 commit comments