Add system prompt and tool permission to agent2 (#35781)
Release Notes: - N/A --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
4dbd24d75f
commit
03876d076e
21 changed files with 1111 additions and 304 deletions
|
@ -19,6 +19,10 @@ impl AgentTool for EchoTool {
|
|||
"echo".into()
|
||||
}
|
||||
|
||||
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(self: Arc<Self>, input: Self::Input, _cx: &mut App) -> Task<Result<String>> {
|
||||
Task::ready(Ok(input.text))
|
||||
}
|
||||
|
@ -40,6 +44,10 @@ impl AgentTool for DelayTool {
|
|||
"delay".into()
|
||||
}
|
||||
|
||||
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(self: Arc<Self>, input: Self::Input, cx: &mut App) -> Task<Result<String>>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -51,6 +59,31 @@ impl AgentTool for DelayTool {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(JsonSchema, Serialize, Deserialize)]
|
||||
pub struct ToolRequiringPermissionInput {}
|
||||
|
||||
pub struct ToolRequiringPermission;
|
||||
|
||||
impl AgentTool for ToolRequiringPermission {
|
||||
type Input = ToolRequiringPermissionInput;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"tool_requiring_permission".into()
|
||||
}
|
||||
|
||||
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(self: Arc<Self>, _input: Self::Input, cx: &mut App) -> Task<Result<String>>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
cx.foreground_executor()
|
||||
.spawn(async move { Ok("Allowed".to_string()) })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(JsonSchema, Serialize, Deserialize)]
|
||||
pub struct InfiniteToolInput {}
|
||||
|
||||
|
@ -63,6 +96,10 @@ impl AgentTool for InfiniteTool {
|
|||
"infinite".into()
|
||||
}
|
||||
|
||||
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(self: Arc<Self>, _input: Self::Input, cx: &mut App) -> Task<Result<String>> {
|
||||
cx.foreground_executor().spawn(async move {
|
||||
future::pending::<()>().await;
|
||||
|
@ -100,6 +137,10 @@ impl AgentTool for WordListTool {
|
|||
"word_list".into()
|
||||
}
|
||||
|
||||
fn needs_authorization(&self, _input: Self::Input, _cx: &App) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn run(self: Arc<Self>, _input: Self::Input, _cx: &mut App) -> Task<Result<String>> {
|
||||
Task::ready(Ok("ok".to_string()))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue