tools: each module exports only tool() or tools(), nothing else
Every tool module now has a clean interface: - read, write, edit, grep, glob, bash, vision: pub fn tool() -> Tool - web: pub fn tools() -> [Tool; 2] - memory: pub fn memory_tools() -> Vec<Tool> - channels: pub fn tools() -> Vec<Tool> - control: pub fn tools() -> Vec<Tool> Definition and handler functions are private to each module. mod.rs::tools() just chains the module exports. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
fdb8c989f5
commit
ed150df628
10 changed files with 65 additions and 36 deletions
|
|
@ -203,17 +203,11 @@ pub async fn dispatch_shared(
|
|||
/// Return all registered tools with definitions + handlers.
|
||||
pub fn tools() -> Vec<Tool> {
|
||||
let mut all = vec![
|
||||
// File tools
|
||||
Tool { def: read::definition(), handler: |_a, v| Box::pin(async move { read::read_file(&v) }) },
|
||||
Tool { def: write::definition(), handler: |_a, v| Box::pin(async move { write::write_file(&v) }) },
|
||||
Tool { def: edit::definition(), handler: |_a, v| Box::pin(async move { edit::edit_file(&v) }) },
|
||||
Tool { def: grep::definition(), handler: |_a, v| Box::pin(async move { grep::grep(&v) }) },
|
||||
Tool { def: glob::definition(), handler: |_a, v| Box::pin(async move { glob::glob_search(&v) }) },
|
||||
Tool { def: bash::definition(), handler: |_a, v| Box::pin(async move { bash::run_bash(&v).await }) },
|
||||
Tool { def: web::fetch_definition(), handler: |_a, v| Box::pin(async move { web::web_fetch(&v).await }) },
|
||||
Tool { def: web::search_definition(), handler: |_a, v| Box::pin(async move { web::web_search(&v).await }) },
|
||||
Tool { def: vision::definition(), handler: |_a, v| Box::pin(async move { vision::view_image_text(&v) }) },
|
||||
read::tool(), write::tool(), edit::tool(),
|
||||
grep::tool(), glob::tool(), bash::tool(),
|
||||
vision::tool(),
|
||||
];
|
||||
all.extend(web::tools());
|
||||
all.extend(memory::memory_tools());
|
||||
all.extend(channels::tools());
|
||||
all.extend(control::tools());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue