claude

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package claude provides Anthropic Claude LLM provider integration.

Index

Constants

This section is empty.

Variables

View Source
var ErrClaudeStreamError = errors.New("claude stream error")

ErrClaudeStreamError marks a failure Anthropic reported mid-stream through an error event. The wrapping error carries the error type and message.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	providers.BaseProvider
	// contains filtered or unexported fields
}

Provider implements the Provider interface for Anthropic Claude

func NewProvider

func NewProvider(id, model, baseURL string, defaults providers.ProviderDefaults, includeRawOutput bool) *Provider

NewProvider creates a new Claude provider

func NewProviderWithCredential

func NewProviderWithCredential(
	id, model, baseURL string, defaults providers.ProviderDefaults,
	includeRawOutput bool, cred providers.Credential,
	platform string, platformConfig *providers.PlatformConfig,
) *Provider

NewProviderWithCredential creates a new Claude provider with explicit credential.

When baseURL is empty the URL is derived from platformConfig for the platforms that support it: Vertex (`publishers/anthropic/models`) and Azure (`openai/deployments/{deployment}`). Callers that pass an explicit baseURL always win.

func (*Provider) CalculateCost

func (p *Provider) CalculateCost(tokensIn, tokensOut, cachedTokens int) types.CostInfo

CalculateCost calculates detailed cost breakdown including optional cached tokens. Thin wrapper over costFromUsage, kept for the Provider interface's legacy signature (cachedTokens here means cache READS only — callers that also have cache-write counts, e.g. wire claudeUsage, should call costFromUsage directly instead so cache writes aren't dropped).

func (*Provider) GetMultimodalCapabilities

func (p *Provider) GetMultimodalCapabilities() providers.MultimodalCapabilities

GetMultimodalCapabilities returns Claude's multimodal support capabilities. When the provider config declares its capabilities, the declaration is authoritative for which modalities are enabled; otherwise Claude's built-in defaults apply (images + documents, no audio/video).

func (*Provider) Model

func (p *Provider) Model() string

Model returns the model name/identifier used by this provider.

func (*Provider) Predict

Predict sends a predict request to Claude

func (*Provider) PredictStream

func (p *Provider) PredictStream(
	ctx context.Context, req providers.PredictionRequest,
) (<-chan providers.StreamChunk, error)

PredictStream performs a streaming prediction request to Claude. On Bedrock, falls back to non-streaming Predict since Bedrock uses binary event-stream encoding that requires AWS-specific parsing.

func (*Provider) SupportsPromptCaching

func (p *Provider) SupportsPromptCaching() bool

SupportsPromptCaching reports whether prompt caching is active for this provider (supported and not disabled by config). The pipeline uses this to decide whether a zero-cache-read tool loop is worth warning about, so providers without caching don't produce false "caching not engaging" warnings.

type ToolProvider

type ToolProvider struct {
	*Provider
	// contains filtered or unexported fields
}

ToolProvider extends ClaudeProvider with tool support

func NewToolProvider

func NewToolProvider(id, model, baseURL string, defaults providers.ProviderDefaults, includeRawOutput bool) *ToolProvider

NewToolProvider creates a new Claude provider with tool support

func NewToolProviderWithCredential

func NewToolProviderWithCredential(
	id, model, baseURL string, defaults providers.ProviderDefaults,
	includeRawOutput bool, cred providers.Credential,
	platform string, platformConfig *providers.PlatformConfig,
) *ToolProvider

NewToolProviderWithCredential creates a Claude tool provider with explicit credential.

func (*ToolProvider) BuildTooling

func (p *ToolProvider) BuildTooling(descriptors []*providers.ToolDescriptor) (providers.ProviderTools, error)

BuildTooling converts tool descriptors to Claude format

func (*ToolProvider) PredictStreamWithTools

func (p *ToolProvider) PredictStreamWithTools(
	ctx context.Context,
	req providers.PredictionRequest,
	tools interface{},
	toolChoice string,
) (<-chan providers.StreamChunk, error)

PredictStreamWithTools performs a streaming predict request with tool support.

func (*ToolProvider) PredictWithTools

PredictWithTools performs a predict request with tool support

Jump to

Keyboard shortcuts

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