Crate miyabi_llm_anthropic

Crate miyabi_llm_anthropic 

Source
Expand description

Anthropic Claude SDK for Miyabi LLM

This crate provides Anthropic Claude API integration for the Miyabi LLM framework. It implements the LlmClient and LlmStreamingClient traits from miyabi-llm-core.

§Features

  • Claude 3.5 Sonnet support
  • Tool/function calling
  • Streaming responses via SSE
  • Environment variable configuration

§Example

use miyabi_llm_anthropic::AnthropicClient;
use miyabi_llm_core::{LlmClient, Message};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AnthropicClient::from_env()?;
    let messages = vec![Message::user("Hello!")];
    let response = client.chat(messages).await?;
    println!("Response: {}", response);
    Ok(())
}

Structs§

AnthropicClient
Anthropic Claude client
AnthropicContent
Content block in Anthropic response
AnthropicMessage
Anthropic message format
AnthropicResponse
Anthropic API response
AnthropicTool
Anthropic tool definition
AnthropicUsage
Token usage information
Message
Message in a conversation
ToolCall
Tool call from LLM
ToolDefinition
Tool definition for LLM Function Calling

Enums§

LlmError
Core LLM error type
Role
Message role
StreamEvent
Stream event type for more detailed streaming information
ToolCallResponse
Response from LLM with tool calling support

Traits§

LlmClient
LLM Client trait - unified interface for all providers
LlmStreamingClient
LLM Streaming Client trait

Type Aliases§

Result
Result type for LLM operations
StreamResponse
Type alias for streaming response