assistant: Add tool registry (#17331)
This PR adds a tool registry to hold tools that can be called by the Assistant. Currently we just have a `now` tool for retrieving the current datetime. This is all behind the `assistant-tool-use` feature flag which currently needs to be explicitly opted-in to in order for the LLM to see the tools. Release Notes: - N/A
This commit is contained in:
parent
c2448e1673
commit
e81b484bf2
11 changed files with 243 additions and 2 deletions
|
@ -13,11 +13,13 @@ pub(crate) mod slash_command_picker;
|
|||
pub mod slash_command_settings;
|
||||
mod streaming_diff;
|
||||
mod terminal_inline_assistant;
|
||||
mod tools;
|
||||
mod workflow;
|
||||
|
||||
pub use assistant_panel::{AssistantPanel, AssistantPanelEvent};
|
||||
use assistant_settings::AssistantSettings;
|
||||
use assistant_slash_command::SlashCommandRegistry;
|
||||
use assistant_tool::ToolRegistry;
|
||||
use client::{proto, Client};
|
||||
use command_palette_hooks::CommandPaletteFilter;
|
||||
pub use context::*;
|
||||
|
@ -214,6 +216,7 @@ pub fn init(
|
|||
prompt_library::init(cx);
|
||||
init_language_model_settings(cx);
|
||||
assistant_slash_command::init(cx);
|
||||
assistant_tool::init(cx);
|
||||
assistant_panel::init(cx);
|
||||
context_servers::init(cx);
|
||||
|
||||
|
@ -228,6 +231,7 @@ pub fn init(
|
|||
.map(Arc::new)
|
||||
.unwrap_or_else(|| Arc::new(prompts::PromptBuilder::new(None).unwrap()));
|
||||
register_slash_commands(Some(prompt_builder.clone()), cx);
|
||||
register_tools(cx);
|
||||
inline_assistant::init(
|
||||
fs.clone(),
|
||||
prompt_builder.clone(),
|
||||
|
@ -401,6 +405,11 @@ fn update_slash_commands_from_settings(cx: &mut AppContext) {
|
|||
}
|
||||
}
|
||||
|
||||
fn register_tools(cx: &mut AppContext) {
|
||||
let tool_registry = ToolRegistry::global(cx);
|
||||
tool_registry.register_tool(tools::now_tool::NowTool);
|
||||
}
|
||||
|
||||
pub fn humanize_token_count(count: usize) -> String {
|
||||
match count {
|
||||
0..=999 => count.to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue