Skip to content

Commit adfe433

Browse files
committed
dev: add add_tool_dyn
1 parent 1f8d139 commit adfe433

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

async-openai/src/tools.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ impl ToolManager {
125125

126126
/// Adds a new tool to the manager.
127127
pub fn add_tool<T: Tool + 'static>(&mut self, tool: T) {
128-
self.tools.insert(T::name(), Arc::new(tool));
128+
self.tools
129+
.insert(T::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(&mut self, tool: Arc<dyn ToolDyn>) {
136+
self.tools.insert(tool.definition().function.name, tool);
129137
}
130138

131139
/// Removes a tool from the manager.

0 commit comments

Comments
 (0)