Documentation ¶
Index ¶
Constants ¶
View Source
const ( ModelClaude3Opus = "claude-3-opus-20240229" ModelClaude3Sonnet = "claude-3-sonnet-20240229" ModelClaude3Haiku = "claude-3-haiku-20240307" // legacy models ModelClaude21 = "claude-2.1" ModelClaudeInstant12 = "claude-instant-1.2" )
View Source
const ( StopReasonMaxTokens string = "max_tokens" StopReasonStopSequence string = "stop_sequence" StopReasonEndTurn string = "end_turn" )
View Source
const ( ContentTypeText string = "text" ContentTypeImage string = "image" )
View Source
const ( ContentBlockMediaTypeImagePng string = "image/png" ContentBlockMediaTypeImageJpeg string = "image/jpeg" ContentBlockMediaTypeImageGif string = "image/gif" ContentBlockMediaTypeImageWebp string = "image/webp" )
View Source
const ( RoleUser string = "user" RoleAssistant string = "assistant" )
Variables ¶
View Source
var ( ModelAliases = map[string]string{ "opus": ModelClaude3Opus, "sonnet": ModelClaude3Sonnet, "haiku": ModelClaude3Haiku, } BaseURL = "https://api.anthropic.com" APIVersion = "2023-06-01" DefaultMaxTokensToSample = 1200 )
Functions ¶
This section is empty.
Types ¶
type ContentBlock ¶ added in v1.15.0
type ContentBlock struct { Type string `json:"type"` Text string `json:"text,omitempty"` // Source is only present if the type is "image" Source *ContentBlockSource `json:"source,omitempty"` }
type ContentBlockSource ¶ added in v1.15.0
type ErrorBlock ¶ added in v1.15.0
type Message ¶ added in v1.15.0
type Message struct { Role string `json:"role"` Content []ContentBlock `json:"content"` }
type MessagesRequest ¶ added in v1.15.0
type MessagesResponse ¶ added in v1.15.0
type MessagesResponse struct { ID string `json:"id"` Type string `json:"type"` // always "message" Error ErrorBlock `json:"error,omitempty"` Role string `json:"role"` // always "assistant" Content []ContentBlock `json:"content"` Model string `json:"model"` StopReason string `json:"stop_reason"` StopSequence string `json:"stop_sequence,omitempty"` Usage Usage `json:"usage"` }
type Request ¶ added in v1.15.0
type Request struct { HTTPClient *http.Client C chan string Endpoint string APIKey string APIVersion string }
func NewMessagesRequest ¶ added in v1.15.0
func NewMessagesRequest() *Request
func (*Request) Stream ¶ added in v1.15.0
func (c *Request) Stream(mr *MessagesRequest) error
Click to show internal directories.
Click to hide internal directories.