Versions in this module Expand all Collapse all v1 v1.0.2 Apr 25, 2024 Changes in this version + const AnthropicAPIMessagesBeta + const AnthropicAPIToolsBeta + const AnthropicAPIVersion + const CompletionEventTypeCompletion + const CompletionEventTypePing + const MessageEventTypeContentBlockDelta + const MessageEventTypeContentBlockStart + const MessageEventTypeContentBlockStop + const MessageEventTypeMessageDelta + const MessageEventTypeMessageStart + const MessageEventTypeMessageStop + const MessageEventTypePing + var ErrAnthropicApiKeyRequired = errors.New("apiKey is required") + var ErrAnthropicForbidden = errors.New(...) + var ErrAnthropicInternalServer = errors.New("an unexpected error has occurred internal to Anthropic's systems") + var ErrAnthropicInvalidRequest = errors.New(...) + var ErrAnthropicRateLimit = errors.New("your account has hit a rate limit") + var ErrAnthropicUnauthorized = errors.New("unauthorized: there's an issue with your API key") + type Client struct + func NewClient(apiKey string, opts ...ClientOptions) (*Client, error) + func (c *Client) Complete(req *CompletionRequest) (*CompletionResponse, error) + func (c *Client) CompleteStream(req *CompletionRequest) (<-chan StreamResponse, <-chan error) + func (c *Client) Message(req *MessageRequest) (*MessageResponse, error) + func (c *Client) MessageStream(req *MessageRequest) (<-chan MessageStreamResponse, <-chan error) + type ClientOptions func(opt *clientOption) + func WithClientBaseURL(baseURl string) ClientOptions + type CompletionEventType string + type CompletionOption func(*CompletionRequest) + type CompletionRequest struct + MaxTokensToSample int + Model Model + Prompt string + StopSequences []string + Stream bool + Temperature float64 + TopK int + TopP float64 + func NewCompletionRequest(prompt string, options ...GenericOption[CompletionRequest]) *CompletionRequest + type CompletionResponse struct + Completion string + Stop string + StopReason string + type ContentBlock interface + func NewImageContentBlock(mediaType MediaType, base64Data string) ContentBlock + func NewTextContentBlock(text string) ContentBlock + type ContentBlockDeltaEvent struct + Delta struct{ ... } + Index int + type ContentBlockStartEvent struct + ContentBlock struct{ ... } + Index int + type ContentBlockStopEvent struct + Index int + type GenericOption func(*T) + func WithMaxTokens[T any](maxTokens int) GenericOption[T] + func WithMessages[T MessageRequest](messages []MessagePartRequest) GenericOption[T] + func WithMetadata[T MessageRequest](metadata interface{}) GenericOption[T] + func WithModel[T any](model Model) GenericOption[T] + func WithStopSequences[T any](stopSequences []string) GenericOption[T] + func WithStream[T any](stream bool) GenericOption[T] + func WithStreaming[T any](stream bool) GenericOption[T] + func WithSystemPrompt[T MessageRequest](systemPrompt string) GenericOption[T] + func WithTemperature[T any](temperature float64) GenericOption[T] + func WithTopK[T any](topK int) GenericOption[T] + func WithTopP[T any](topP float64) GenericOption[T] + type ImageContentBlock struct + Source ImageSource + Type string + type ImageSource struct + Data string + MediaType MediaType + Type string + type InputSchema struct + Properties map[string]Property + Required []string + Type string + type MediaType string + const MediaTypeGIF + const MediaTypeJPEG + const MediaTypePNG + const MediaTypeWEBP + type MessageDeltaEvent struct + Delta struct{ ... } + Usage struct{ ... } + type MessageErrorEvent struct + Error struct{ ... } + type MessageEvent struct + Type string + type MessageEventType string + type MessageOption func(*MessageRequest) + type MessagePartRequest struct + Content []ContentBlock + Role string + type MessagePartResponse struct + ID string + Input map[string]interface{} + Name string + Text string + Type string + type MessageRequest struct + MaxTokensToSample int + Messages []MessagePartRequest + Metadata interface{} + Model Model + StopSequences []string + Stream bool + SystemPrompt string + Temperature float64 + Tools []Tool + TopK int + TopP float64 + func NewMessageRequest(messages []MessagePartRequest, options ...GenericOption[MessageRequest]) *MessageRequest + func (m *MessageRequest) ContainsImageContent() bool + func (m *MessageRequest) CountImageContent() int + type MessageResponse struct + Content []MessagePartResponse + ID string + Model string + Role string + Stop string + StopReason string + StopSequence string + Type string + Usage MessageUsage + type MessageStartEvent struct + Message struct{ ... } + type MessageStopEvent struct + type MessageStreamDelta struct + StopReason string + StopSequence string + Text string + Type string + type MessageStreamResponse struct + Delta MessageStreamDelta + Type string + Usage MessageStreamUsage + type MessageStreamUsage struct + InputTokens int + OutputTokens int + type MessageUsage struct + InputTokens int + OutputTokens int + type Model string + const Claude3Haiku + const Claude3Opus + const Claude3Sonnet + const ClaudeInstantV1 + const ClaudeInstantV1_0 + const ClaudeInstantV1_1 + const ClaudeInstantV1_100k + const ClaudeInstantV1_1_100k + const ClaudeV1 + const ClaudeV1_0 + const ClaudeV1_100k + const ClaudeV1_2 + const ClaudeV1_3 + const ClaudeV1_3_100k + const ClaudeV2 + const ClaudeV2_1 + func (m Model) IsCompleteCompatible() bool + func (m Model) IsImageCompatible() bool + func (m Model) IsMessageCompatible() bool + type PingEvent struct + type Property struct + Description string + Enum []string + Type string + type StreamResponse struct + Completion string + LogID string + Model string + Stop string + StopReason string + type TextContentBlock struct + Text string + Type string + type Tool struct + Description string + InputSchema InputSchema + Name string + type UnsupportedEventType struct + Code int + Msg string + func (e UnsupportedEventType) Error() string v1.0.1 Apr 24, 2024