Documentation
¶
Overview ¶
anthropic implements an API client for anthropic https://docs.anthropic.com/en/api/getting-started
Index ¶
- func WithCitations() llm.Opt
- func WithEphemeral() llm.Opt
- type Client
- func (anthropic *Client) GetModel(ctx context.Context, name string) (*Model, error)
- func (anthropic *Client) ListModels(ctx context.Context) ([]Model, error)
- func (anthropic *Client) Model(ctx context.Context, name string) llm.Model
- func (anthropic *Client) Models(ctx context.Context) ([]llm.Model, error)
- func (*Client) Name() string
- type Content
- type ContentAttachment
- type ContentText
- type ContentTool
- type ContentToolResult
- type Message
- func (Message) Attachment(index int) *llm.Attachment
- func (message Message) Choice(index int) llm.Completion
- func (Message) Num() int
- func (message Message) Role() string
- func (m Message) String() string
- func (message Message) Text(index int) string
- func (message Message) ToolCalls(index int) []llm.ToolCall
- type Metrics
- type Model
- type Response
- type RoleContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCitations ¶
func WithEphemeral ¶
Types ¶
type Client ¶
type Client struct { *client.Client *impl.ModelCache }
func (*Client) ListModels ¶
List models
func (*Client) Model ¶ added in v0.0.3
Return a model by name, or nil if not found. Panics on error.
type Content ¶
type Content struct { Type string `json:"type"` // image, document, text, tool_use ContentText ContentAttachment *ContentTool ContentToolResult CacheControl *cachecontrol `json:"cache_control,omitempty"` // ephemeral }
func NewAttachment ¶ added in v0.0.5
func NewAttachment(attachment *llm.Attachment, ephemeral, citations bool) (*Content, error)
Make attachment content
func NewTextContent ¶
Return a content object with text content
func NewToolResultContent ¶
func NewToolResultContent(v llm.ToolResult) *Content
Return a content object with tool result
type ContentAttachment ¶
type ContentAttachment struct { Title string `json:"title,omitempty"` // title of the document Context string `json:"context,omitempty"` // context of the document Citations *contentcitation `json:"citations,omitempty"` // citations of the document Source *contentsource `json:"source,omitempty"` // image or document content }
type ContentText ¶
type ContentText struct {
Text string `json:"text,omitempty"` // text content
}
type ContentTool ¶
type ContentToolResult ¶
type Message ¶ added in v0.0.5
type Message struct {
RoleContent
}
Message with text or object content
func (Message) Attachment ¶ added in v0.0.10
func (Message) Attachment(index int) *llm.Attachment
Return the audio - unsupported
func (Message) Choice ¶ added in v0.0.6
func (message Message) Choice(index int) llm.Completion
Return the completion
type Metrics ¶
type Metrics struct { CacheCreationInputTokens uint `json:"cache_creation_input_tokens,omitempty"` CacheReadInputTokens uint `json:"cache_read_input_tokens,omitempty"` InputTokens uint `json:"input_tokens,omitempty"` OutputTokens uint `json:"output_tokens,omitempty"` }
Metrics
type Response ¶
type Response struct { Id string `json:"id"` Type string `json:"type"` Model string `json:"model"` Reason string `json:"stop_reason,omitempty"` StopSequence *string `json:"stop_sequence,omitempty"` Message *Metrics `json:"usage,omitempty"` }
Chat Completion Response
type RoleContent ¶ added in v0.0.5
Click to show internal directories.
Click to hide internal directories.