forked from kent/consciousness
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
|
|
@ -21,7 +21,7 @@ struct Args {
|
|||
|
||||
fn default_lines() -> usize { 50 }
|
||||
|
||||
pub(super) fn definition() -> ToolDef {
|
||||
fn definition() -> ToolDef {
|
||||
ToolDef::new(
|
||||
"view_image",
|
||||
"View an image file or capture a tmux pane screenshot. \
|
||||
|
|
@ -48,8 +48,12 @@ pub(super) fn definition() -> ToolDef {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn tool() -> super::Tool {
|
||||
super::Tool { def: definition(), handler: |_a, v| Box::pin(async move { view_image_text(&v) }) }
|
||||
}
|
||||
|
||||
/// Text-only version for the Tool registry.
|
||||
pub fn view_image_text(args: &serde_json::Value) -> anyhow::Result<String> {
|
||||
fn view_image_text(args: &serde_json::Value) -> anyhow::Result<String> {
|
||||
let output = view_image(args)?;
|
||||
Ok(output.text)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue