2 releases

Uses new Rust 2024

new 0.1.1 Apr 30, 2025
0.1.0 Apr 30, 2025

#644 in Machine learning

Download history 126/week @ 2025-04-25

126 downloads per month
Used in blitzdenk

Custom license

31KB
904 lines

Blitzagent

A simple forward multi API agent framework.

It's a pipe!

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let (ctx, rec) = AgentContext::new(root, OllamaClient::new(config.ollama_model))
    let agent = ctx.new_agent::<DevAgent>();

    agent.chat.push_message(Message::User("list all files".into()));
    agent.run().await?;

    loop {
        let msg = rec.recv().unwrap();
        println("{}", msg);
    }
}


#[derive(Default)]
pub struct DevAgent;
impl AgentInstruction for DevAgent {
    fn sys_prompt(&self) -> &'static str {
        crate::prompts::ASSISTANT_PROMPT
    }

    fn toolset(&self) -> Vec<Box<dyn AiTool>> {
        vec![
            Box::new(tools::Tree),
        ]
    }
}

#[derive(Default)]
pub struct Tree;
#[async_trait]
impl AiTool for Tree {
    fn name(&self) -> &'static str {
        "tree"
    }

    fn description(&self) -> &'static str {
        "Prints the current project structure with all file paths."
    }

    fn args(&self) -> Vec<Argument> {
        vec![]
    }

    async fn run(&self, ctx: AgentContext, _args: AgentArgs) -> BResult<Message> {

        // tools can create new agents and await their final response.
        // let child_agent = ctx.new_agent::<DevAgent>();

        let result = tokio::process::Command::new("tree")
            .arg("-f")
            .arg("-i")
            .arg("--gitignore")
            .current_dir(ctx.cwd)
            .output()
            .await?;

        let content = String::from_utf8_lossy(&result.stdout).to_string();
        Ok(Message::tool(content, None))
    }
}

Dependencies

~8–19MB
~250K SLoC