Hi! I just started experimenting with Rig and ran into a couple docs examples that do not compile for me.
I am using rig-core = 0.36.0.
1) Quickstart example: Client::from_env() result is not handled
Page: https://docs.rig.rs/docs/quickstart/getting_started
Current snippet:
use rig::client::{CompletionClient, ProviderClient};
use rig::completion::Prompt;
use rig::providers::openai;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create OpenAI client
let client = openai::Client::from_env();
// Create agent with a single context prompt
let comedian_agent = client
.agent("gpt-5.2")
.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(())
}
Client::from_env() returns Result<T, E>, so this would need a ? to propagate the error up or explicit error handling.
2) CLI chatbot example uses old API shape
Page: https://docs.rig.rs/docs/extensions/cli_chatbot
Current snippet:
use rig::{cli_chatbot, providers::openai};
let agent = openai.agent("gpt-4")
.preamble("You are a helpful assistant.")
.build();
cli_chatbot(agent).await?;
To my knowledge, cli_chatbot is a module, not a callable function in rig-core 0.36.0.
Suggested fix is builder-based:
use rig::integrations::cli_chatbot::ChatBotBuilder;
// ...
let chatbot = ChatBotBuilder::new().agent(agent).build();
chatbot.run().await?;
If this looks right, I’m happy to open a PR with these fixes. Should I go ahead?
Hi! I just started experimenting with Rig and ran into a couple docs examples that do not compile for me.
I am using
rig-core = 0.36.0.1) Quickstart example:
Client::from_env()result is not handledPage:
https://docs.rig.rs/docs/quickstart/getting_startedCurrent snippet:
Client::from_env()returnsResult<T, E>, so this would need a?to propagate the error up or explicit error handling.2) CLI chatbot example uses old API shape
Page:
https://docs.rig.rs/docs/extensions/cli_chatbotCurrent snippet:
To my knowledge,
cli_chatbotis a module, not a callable function inrig-core 0.36.0.Suggested fix is builder-based:
If this looks right, I’m happy to open a PR with these fixes. Should I go ahead?