assistant: Add basic tool invocation (#17368)
This PR adds the initial groundwork for invoking tools in response to tool uses from the model. Tool uses are run when the model responds with a `stop_reason` of `tool_use`. Currently the tool results are just inserted as text into the user message. We'll want to include these as `tool_result` content on the message, but Claude seems to understand it regardless. Release Notes: - N/A
This commit is contained in:
parent
7fb94c4c4d
commit
01525f17fa
3 changed files with 92 additions and 10 deletions
|
@ -66,4 +66,9 @@ impl ToolRegistry {
|
|||
pub fn tools(&self) -> Vec<Arc<dyn Tool>> {
|
||||
self.state.read().tools.values().cloned().collect()
|
||||
}
|
||||
|
||||
/// Returns the [`Tool`] with the given name.
|
||||
pub fn tool(&self, name: &str) -> Option<Arc<dyn Tool>> {
|
||||
self.state.read().tools.get(name).cloned()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue