ante-llm 0.4.2

Streaming LLM client for Anthropic, OpenAI, Gemini and Chat Completions servers, from the Ante coding agent
Documentation
// Copyright 2026 Antigma Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//! Fixtures for the provider tests.

use crate::auth::AuthedClient;
use crate::client::Client;
use crate::types::{
    Attachment, ChatRequest, Content, ContentPart, Message, ModelSpec, ToolDefinition, ToolResult,
    ToolUse,
};

/// A client for `base_url` that sends no credential.
pub(crate) fn unauthenticated(base_url: impl Into<String>) -> Client {
    Client::new(base_url, AuthedClient::unauthenticated(reqwest::Client::new()))
}

/// A request for the model `id` over `messages`, with no system prompt and
/// no tools.
pub(crate) fn chat_request(id: &str, messages: Vec<Message>) -> ChatRequest {
    messages.into_iter().fold(ChatRequest::new(id), ChatRequest::with_message)
}

/// A request for the model `id` with these system prompts over `messages`.
pub(crate) fn prompted(id: &str, system: &[&str], messages: Vec<Message>) -> ChatRequest {
    system.iter().fold(chat_request(id, messages), |request, text| request.with_system(*text))
}

/// One question for `model`, with a stub of each named tool on offer.
pub(crate) fn tool_request(model: &ModelSpec, tools: &[&str]) -> ChatRequest {
    ChatRequest::for_model(model)
        .with_tools(tools.iter().copied().map(ToolDefinition::stub).collect())
        .with_user_text("hi")
}

/// The user message that answers tool calls.
pub(crate) fn tool_results(results: Vec<ToolResult>) -> Message {
    Message::user(Content::Parts(results.into_iter().map(ContentPart::ToolResult).collect()))
}

/// Both attachment sources, in user input and a tool result.
pub(crate) fn image_request() -> ChatRequest {
    let content = Content::Parts(vec![
        ContentPart::Text("Look:".into()),
        ContentPart::Image(Attachment::Base64 {
            media_type: "image/png".into(),
            data: "aW1hZ2U=".into(),
        }),
        ContentPart::Image(Attachment::Url { url: "https://example.com/image.png".into() }),
    ]);
    chat_request(
        "test-model",
        vec![
            Message::user(content.clone()),
            Message::model_content(Content::Parts(vec![ContentPart::ToolUse(ToolUse::new(
                "call-image",
                "screenshot",
                serde_json::json!({}),
            ))])),
            tool_results(vec![ToolResult::ok("call-image".into(), content)]),
        ],
    )
    .with_tools(vec![ToolDefinition::stub("screenshot")])
}