Documentation
¶
Index ¶
- func ConvertParametersToSchema(params any) (anthropic.ToolInputSchemaParam, error)
- type Client
- func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, ...) (*Client, error)
- func NewClientFromFactory(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, ...) (*Client, error)
- func NewClientFromFactoryWithOptions(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, ...) (*Client, error)
- func (c *Client) CompactConversation(ctx context.Context, messages []chat.Message, requestTools []tools.Tool, ...) (*chat.CompactionResult, error)
- func (c *Client) CreateChatCompletionStream(ctx context.Context, messages []chat.Message, requestTools []tools.Tool) (chat.MessageStream, error)
- func (c *Client) Rerank(ctx context.Context, query string, documents []types.Document, criteria string) ([]float64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertParametersToSchema ¶
func ConvertParametersToSchema(params any) (anthropic.ToolInputSchemaParam, error)
ConvertParametersToSchema converts parameters to Anthropic Schema format
Types ¶
type Client ¶
Client represents an Anthropic client wrapper implementing provider.Provider It holds the anthropic client and model config
func NewClient ¶
func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, opts ...options.Opt) (*Client, error)
NewClient creates a new Anthropic client from the provided configuration
func NewClientFromFactory ¶ added in v1.115.0
func NewClientFromFactory(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, factory func(context.Context) (anthropic.Client, error), opts ...options.Opt) (*Client, error)
NewClientFromFactory creates a Client backed by the SDK client returned by factory. Config validation runs before factory is invoked, so configuration errors surface without requiring provider credentials. The factory is called once during construction and the returned client is cached for the lifetime of the Client. It is the wiring point for subpackages that target alternative endpoints, such as github.com/docker/docker-agent/pkg/model/provider/anthropic/vertex.
func NewClientFromFactoryWithOptions ¶ added in v1.142.0
func NewClientFromFactoryWithOptions(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, factory func(context.Context, options.ModelOptions) (anthropic.Client, error), opts ...options.Opt) (*Client, error)
NewClientFromFactoryWithOptions is NewClientFromFactory for factories that need the applied options (e.g. options.TokenSource). Options are applied exactly once, before the factory runs, and the factory receives the result.
func (*Client) CompactConversation ¶ added in v1.142.0
func (c *Client) CompactConversation(ctx context.Context, messages []chat.Message, requestTools []tools.Tool, instructions string) (*chat.CompactionResult, error)
CompactConversation summarizes the entire supplied conversation. The runtime persists the signed block before replacing history; failures never discard it.
func (*Client) CreateChatCompletionStream ¶
func (c *Client) CreateChatCompletionStream( ctx context.Context, messages []chat.Message, requestTools []tools.Tool, ) (chat.MessageStream, error)
CreateChatCompletionStream creates a streaming chat completion request
func (*Client) Rerank ¶
func (c *Client) Rerank(ctx context.Context, query string, documents []types.Document, criteria string) ([]float64, error)
Rerank scores documents by relevance to the query using Anthropic's Beta Messages API with structured outputs. It returns relevance scores in the same order as input documents.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package federation builds the Anthropic Workload Identity Federation pieces (identity-token providers and SDK request options) from a typed latest.AuthConfig.
|
Package federation builds the Anthropic Workload Identity Federation pieces (identity-token providers and SDK request options) from a typed latest.AuthConfig. |
|
Package vertex provides an Anthropic client for Claude models hosted on Google Cloud's Vertex AI.
|
Package vertex provides an Anthropic client for Claude models hosted on Google Cloud's Vertex AI. |