Docs   ExtensionsCLI Chatbot

CLI Chatbot Utility

Overview

A utility function that creates an interactive REPL-style chatbot from any type implementing the Chat trait. Manages chat history, I/O, and basic command handling.

Features

  • Interactive REPL interface with > prompt
  • Maintains chat history for context
  • Simple “exit” command
  • Error handling for I/O and chat operations
  • Tracing support for debugging

Usage

use rig::{cli_chatbot, providers::openai};
 
let agent = openai.agent("gpt-4")
    .preamble("You are a helpful assistant.")
    .build();
 
cli_chatbot(agent).await?;

See Also

API Reference (CLI Chatbot)