Skip to main content

call_chatbot_tool

Function call_chatbot_tool 

Source
pub async fn call_chatbot_tool(
    conn: &mut PgConnection,
    app_config: &ApplicationConfiguration,
    fn_name: &str,
    fn_args: &str,
    user_context: &ChatbotTurnContext,
) -> ChatbotResult<ChatbotToolCallResult>
Expand description

Run the chatbot tool the LLM asked for and return its arguments and its LLM-readable output.

fn_args is the raw argument JSON from the LLM; each tool parses it itself and tools that take no arguments ignore it. Arguments are parsed before the caller is authorized, because what the call targets is what decides the answer. Fails with InvalidToolName when no tool claims fn_name, which happens when the LLM hallucinates a tool.