Skip to main content

run_chat

Function run_chat 

Source
pub async fn run_chat(
    message: &str,
    model: Option<String>,
    system_prompt: Option<String>,
) -> Result<String>
Expand description

Sends a single user message to the configured AI and returns the response.

Shared between the MCP ai_chat tool and any non-interactive CLI callers. The function performs the same preflight credential check as the CLI chat loop — on missing credentials it returns the preflight error verbatim so MCP tool callers see the same diagnostic message the CLI would print.

model selects the AI model; None uses the environment default. system_prompt defaults to "You are a helpful assistant." (matching the CLI’s default) when None.