assistant2: Decouple scripting tool from the Tool
trait (#26382)
This PR decouples the scripting tool from the `Tool` trait while still allowing it to be used as a tool from the model's perspective. This will allow us to evolve the scripting tool as more of a first-class citizen while still retaining the ability to have the model call it as a regular tool. Release Notes: - N/A
This commit is contained in:
parent
2fc4dec58f
commit
e513e81046
10 changed files with 138 additions and 52 deletions
|
@ -14,7 +14,6 @@ doctest = false
|
|||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
assistant_tool.workspace = true
|
||||
collections.workspace = true
|
||||
futures.workspace = true
|
||||
gpui.workspace = true
|
||||
|
|
|
@ -3,40 +3,29 @@ mod session;
|
|||
use project::Project;
|
||||
use session::*;
|
||||
|
||||
use assistant_tool::{Tool, ToolRegistry};
|
||||
use gpui::{App, AppContext as _, Entity, Task};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn init(cx: &App) {
|
||||
let registry = ToolRegistry::global(cx);
|
||||
registry.register_tool(ScriptingTool);
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, JsonSchema)]
|
||||
struct ScriptingToolInput {
|
||||
lua_script: String,
|
||||
}
|
||||
|
||||
struct ScriptingTool;
|
||||
pub struct ScriptingTool;
|
||||
|
||||
impl Tool for ScriptingTool {
|
||||
fn name(&self) -> String {
|
||||
"lua-interpreter".into()
|
||||
}
|
||||
impl ScriptingTool {
|
||||
pub const NAME: &str = "lua-interpreter";
|
||||
|
||||
fn description(&self) -> String {
|
||||
include_str!("scripting_tool_description.txt").into()
|
||||
}
|
||||
pub const DESCRIPTION: &str = include_str!("scripting_tool_description.txt");
|
||||
|
||||
fn input_schema(&self) -> serde_json::Value {
|
||||
pub fn input_schema() -> serde_json::Value {
|
||||
let schema = schemars::schema_for!(ScriptingToolInput);
|
||||
serde_json::to_value(&schema).unwrap()
|
||||
}
|
||||
|
||||
fn run(
|
||||
self: Arc<Self>,
|
||||
pub fn run(
|
||||
&self,
|
||||
input: serde_json::Value,
|
||||
project: Entity<Project>,
|
||||
cx: &mut App,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue