cliai 0.2.0

A small Rust library for invoking AI tools through CLI backends like Ollama and GitHub Copilot CLI.
Documentation
/// A request sent to an AI backend.
///
/// This separates the current task (`prompt`) from optional behavioral
/// guidance (`persona`, `instructions`) and reusable context (`memory`).
#[derive(Debug, Clone)]
pub struct GenerateRequest {
    /// The task or question for the AI.
    pub prompt: String,

    /// Optional identity, role, tone, or style guidance.
    pub persona: Option<String>,

    /// Optional rules or output constraints.
    pub instructions: Option<String>,

    /// Optional reusable context or prior facts.
    pub memory: Option<String>,
}

impl GenerateRequest {
    /// Creates a new request with a prompt.
    pub fn new(prompt: impl Into<String>) -> Self {
        Self {
            prompt: prompt.into(),
            persona: None,
            instructions: None,
            memory: None,
        }
    }

    /// Sets the persona for the request.
    pub fn with_persona(mut self, persona: impl Into<String>) -> Self {
        self.persona = Some(persona.into());
        self
    }

    /// Sets behavioral instructions for the request.
    pub fn with_instructions(mut self, instructions: impl Into<String>) -> Self {
        self.instructions = Some(instructions.into());
        self
    }

    /// Sets reusable memory/context for the request.
    pub fn with_memory(mut self, memory: impl Into<String>) -> Self {
        self.memory = Some(memory.into());
        self
    }
}