Skip to content

Commit caa218f

Browse files
committed
dev: add add_arc_tool
1 parent 1f8d139 commit caa218f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

async-openai/src/tools.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,17 @@ impl ToolManager {
124124
}
125125

126126
/// Adds a new tool to the manager.
127-
pub fn add_tool<T: Tool + 'static>(&mut self, tool: T) {
128-
self.tools.insert(T::name(), Arc::new(tool));
127+
pub fn add_tool<T: ToolDyn + 'static>(&mut self, tool: T) {
128+
self.tools
129+
.insert(tool.definition().function.name, Arc::new(tool));
130+
}
131+
132+
/// Adds a new tool with an Arc to the manager.
133+
///
134+
/// Use this if you want to access this tool after being added to the manager.
135+
pub fn add_tool_arc<T: ToolDyn + 'static>(&mut self, tool: Arc<T>) {
136+
self.tools
137+
.insert(tool.definition().function.name, tool);
129138
}
130139

131140
/// Removes a tool from the manager.

0 commit comments

Comments
 (0)