A blog to discuss all things Ai Agent Frameworks and Platforms
You already have git, cargo, and rust installed
For git: Find instructions here
For rust and cargo: Find instructions here
Check out my GitHub repository for the source code Rig Hello World
Open a command line terminal and run the following commands
If you haven’t installed Rust yet, install it using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
cargo new rig_hello_world
cd rig_hello_world
cargo add rig-core
cargo add tokio --features full
cargo add anyhow
ollama run llama3.2:1b
/// This example requires that you have the [`ollama`](https://ollama.com) server running locally.
use rig::{completion::Prompt, providers};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create an OpenAI client with a custom base url, a local ollama endpoint
// The API Key is unnecessary for most local endpoints
let client = providers::openai::Client::from_url("ollama", "http://localhost:11434/v1");
// Create agent with a single context prompt
let comedian_agent = client
.agent("llama3.2:1b")
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();
// Prompt the agent and print the response
let response = comedian_agent.prompt("Entertain me!").await?;
println!("{}", response);
Ok(())
}
cargo run
This completes your hello world Rig introduction
Congratulations you have successful run your first Rig Ai Agent