Skip to content

Writing AI agent pipelines in Rust, made easy.

Notifications You must be signed in to change notification settings

MuhammedAhmedH/ai-agents-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Severn: Agent AI pipelines in Rust, made easy.

Do you hate the fact that the llm-chain crate is too macro heavy? Me too. Let's make a new crate that doesn't suck.

How to use

First, you need to define a struct that will serve as your agent:

use severn::agent::Agent;

struct ExampleAgent;

impl ExampleAgent {
    pub fn new() -> Self {
        Self
    }
}

impl Agent for ExampleAgent {
    fn name(&self) -> String {
        "Example agent".into()
    }

    fn system_message(&self) -> String {
        "You are an example agent, Neo. Your job is to serve as an example for all the other agents.".to_string()
    }
}

Next, you can now use your agent by turning it into an Arc<T> and adding your agent to the pipeline:

use std::sync::Arc;
use severn::pipeline::Pipeline;
use anyhow::Result;

#[tokio::main]
async fn main() -> Result<()> {
    let example_agent = Arc::new(ExampleAgent::new());

    assert_eq!(example_agent.name(), String::from("Example agent"));

    let pipeline = Pipeline::new().add_agent(example_agent);
    
    let prompt = "What is your job, Neo?".to_string();
    
    let result = pipeline.run_pipeline(prompt).await?;
    
    println!("{result}");
}

About

Writing AI agent pipelines in Rust, made easy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%