anthropic

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package anthropic provides an Anthropic Claude LLM implementation.

This implementation is strictly aligned with ADK-Go's model architecture:

  • Unified GenerateContent method with stream boolean
  • Returns iter.Seq2[*Response, error]
  • Uses StreamingAggregator for streaming with Partial flag
  • Proper handling of thinking blocks with signatures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an Anthropic LLM implementation. Implements model.LLM interface aligned with ADK-Go.

func New

func New(cfg Config) (*Client, error)

New creates a new Anthropic client.

func (*Client) Close

func (c *Client) Close() error

Close releases resources.

func (*Client) GenerateContent

func (c *Client) GenerateContent(ctx context.Context, req *model.Request, stream bool) iter.Seq2[*model.Response, error]

GenerateContent produces responses for the given request. This is the ADK-Go aligned interface.

When stream=false:

  • Yields exactly one Response with complete content, Partial=false

When stream=true:

  • Yields multiple partial Responses (Partial=true) for real-time UI updates
  • Finally yields aggregated Response (Partial=false) for session persistence

func (*Client) Name

func (c *Client) Name() string

Name returns the model identifier.

func (*Client) Provider

func (c *Client) Provider() model.Provider

Provider returns the provider type.

type Config

type Config struct {
	APIKey              string
	Model               string
	MaxTokens           int
	Temperature         *float64
	BaseURL             string
	Timeout             time.Duration
	MaxRetries          int
	EnableThinking      bool
	ThinkingBudget      int
	MaxToolOutputLength int
}

Config configures the Anthropic client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL