diff --git a/crates/assistant2/src/tools/annotate_code.rs b/crates/assistant2/src/tools/annotate_code.rs index 29a7d8cb96820ad2b091b44f015b40ddb42ced36..afee701054ae78965ea24877170dccad0906f04c 100644 --- a/crates/assistant2/src/tools/annotate_code.rs +++ b/crates/assistant2/src/tools/annotate_code.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use assistant_tooling::{LanguageModelTool, ProjectContext, ToolOutput}; +use assistant_tooling::{LanguageModelTool, ProjectContext, ToolView}; use editor::{ display_map::{BlockContext, BlockDisposition, BlockProperties, BlockStyle}, Editor, MultiBuffer, @@ -230,7 +230,7 @@ impl Render for AnnotationResultView { } } -impl ToolOutput for AnnotationResultView { +impl ToolView for AnnotationResultView { type Input = AnnotationInput; type SerializedState = Option; diff --git a/crates/assistant2/src/tools/create_buffer.rs b/crates/assistant2/src/tools/create_buffer.rs index a290cc3eacbfe7d63a0f01925e58849d2c117046..894ee75d554ab304ffe98fc7143c777100938d8a 100644 --- a/crates/assistant2/src/tools/create_buffer.rs +++ b/crates/assistant2/src/tools/create_buffer.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Result}; -use assistant_tooling::{LanguageModelTool, ProjectContext, ToolOutput}; +use assistant_tooling::{LanguageModelTool, ProjectContext, ToolView}; use editor::Editor; use gpui::{prelude::*, Model, Task, View, WeakView}; use project::Project; @@ -65,7 +65,7 @@ impl Render for CreateBufferView { } } -impl ToolOutput for CreateBufferView { +impl ToolView for CreateBufferView { type Input = CreateBufferInput; type SerializedState = (); diff --git a/crates/assistant2/src/tools/project_index.rs b/crates/assistant2/src/tools/project_index.rs index 0c70528dcf19564000bd74123a28b95aaf7a7f25..5d28d470f3191fc60fbbd88fa27b12c95d6021f1 100644 --- a/crates/assistant2/src/tools/project_index.rs +++ b/crates/assistant2/src/tools/project_index.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use assistant_tooling::{LanguageModelTool, ToolOutput}; +use assistant_tooling::{LanguageModelTool, ToolView}; use collections::BTreeMap; use file_icons::FileIcons; use gpui::{prelude::*, AnyElement, Model, Task}; @@ -232,7 +232,7 @@ impl Render for ProjectIndexView { } } -impl ToolOutput for ProjectIndexView { +impl ToolView for ProjectIndexView { type Input = CodebaseQuery; type SerializedState = SerializedState; diff --git a/crates/assistant_tooling/src/assistant_tooling.rs b/crates/assistant_tooling/src/assistant_tooling.rs index 9a45ad9b1d99960296158b3e28890680d9680630..9dcf2908e92c54f8cdfe0e0140f037334d3d0bc5 100644 --- a/crates/assistant_tooling/src/assistant_tooling.rs +++ b/crates/assistant_tooling/src/assistant_tooling.rs @@ -8,6 +8,6 @@ pub use attachment_registry::{ }; pub use project_context::ProjectContext; pub use tool_registry::{ - LanguageModelTool, SavedToolFunctionCall, ToolFunctionCall, ToolFunctionDefinition, ToolOutput, - ToolRegistry, + LanguageModelTool, SavedToolFunctionCall, ToolFunctionCall, ToolFunctionDefinition, + ToolRegistry, ToolView, }; diff --git a/crates/assistant_tooling/src/tool_registry.rs b/crates/assistant_tooling/src/tool_registry.rs index 98793e4b8fbc616745390077c507fb59681cb4e5..e5f8914eb57c4ca5d65447990b677bdf1fe5c944 100644 --- a/crates/assistant_tooling/src/tool_registry.rs +++ b/crates/assistant_tooling/src/tool_registry.rs @@ -31,11 +31,11 @@ enum ToolFunctionCallState { #[default] Initializing, NoSuchTool, - KnownTool(Box), - ExecutedTool(Box), + KnownTool(Box), + ExecutedTool(Box), } -trait ToolView { +trait InternalToolView { fn view(&self) -> AnyView; fn generate(&self, project: &mut ProjectContext, cx: &mut WindowContext) -> String; fn try_set_input(&self, input: &str, cx: &mut WindowContext); @@ -69,7 +69,7 @@ pub struct ToolFunctionDefinition { } pub trait LanguageModelTool { - type View: ToolOutput; + type View: ToolView; /// Returns the name of the tool. /// @@ -85,7 +85,7 @@ pub trait LanguageModelTool { /// Returns the OpenAI Function definition for the tool, for direct use with OpenAI's API. fn definition(&self) -> ToolFunctionDefinition { - let root_schema = schema_for!(::Input); + let root_schema = schema_for!(::Input); ToolFunctionDefinition { name: self.name(), @@ -98,7 +98,7 @@ pub trait LanguageModelTool { fn view(&self, cx: &mut WindowContext) -> View; } -pub trait ToolOutput: Render { +pub trait ToolView: Render { /// The input type that will be passed in to `execute` when the tool is called /// by the language model. type Input: DeserializeOwned + JsonSchema; @@ -121,7 +121,7 @@ pub trait ToolOutput: Render { struct RegisteredTool { enabled: AtomicBool, type_id: TypeId, - build_view: Box Box>, + build_view: Box Box>, definition: ToolFunctionDefinition, } @@ -304,7 +304,7 @@ impl ToolRegistry { } } -impl ToolView for View { +impl InternalToolView for View { fn view(&self) -> AnyView { self.clone().into() } @@ -404,7 +404,7 @@ mod test { } } - impl ToolOutput for WeatherView { + impl ToolView for WeatherView { type Input = WeatherQuery; type SerializedState = WeatherResult;