Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAnthropicInvalidRequest = errors.New("invalid request: there was an issue with the format or content of your request") ErrAnthropicForbidden = errors.New("forbidden: your API key does not have permission to use the specified resource") ErrAnthropicRateLimit = errors.New("your account has hit a rate limit") ErrAnthropicInternalServer = errors.New("an unexpected error has occurred internal to Anthropic's systems") ErrAnthropicApiKeyRequired = errors.New("apiKey is required") )
Functions ¶
func GetChatPrompt ¶ added in v1.0.1
GetChatPrompt constructs a prompt string from a series of messages in a chat conversation.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the Anthropic API client and its configuration.
func (*Client) Complete ¶
func (c *Client) Complete(req *CompletionRequest, callback StreamCallback) (*CompletionResponse, error)
Complete sends a completion request to the API and returns a single completion or a stream of completions.
type CompletionRequest ¶
type CompletionRequest struct { Prompt string `json:"prompt"` Model Model `json:"model"` MaxTokensToSample int `json:"max_tokens_to_sample"` StopSequences []string `json:"stop_sequences,omitempty"` // optional Stream bool `json:"stream,omitempty"` // optional Temperature float64 `json:"temperature,omitempty"` // optional TopK int `json:"top_k,omitempty"` // optional TopP float64 `json:"top_p,omitempty"` // optional }
CompletionRequest is the request to the Anthropic API for a completion.
type CompletionResponse ¶
type CompletionResponse struct { Completion string `json:"completion"` StopReason string `json:"stop_reason"` Stop string `json:"stop"` }
CompletionResponse is the response from the Anthropic API for a completion request.
type Message ¶ added in v1.0.1
type Message struct { Sender string // The sender's name (e.g., "Human" or a username) Content string // The content of the message }
Message represents a single message in a chat conversation.
type Model ¶
type Model string
Model represents a Claude model.
const ( // Superior performance on tasks that require complex reasoning. ClaudeV2 Model = "claude-2" // Our largest model, ideal for a wide range of more complex tasks. ClaudeV1 Model = "claude-v1" // An enhanced version of ClaudeV1 with a 100,000 token context window. ClaudeV1_100k Model = "claude-v1-100k" // A smaller model with far lower latency, sampling at roughly 40 words/sec! ClaudeInstantV1 Model = "claude-instant-v1" // An enhanced version of ClaudeInstantV1 with a 100,000 token context window. ClaudeInstantV1_100k Model = "claude-instant-v1-100k" // More robust against red-team inputs, better at precise instruction-following, // better at code, and better and non-English dialogue and writing. ClaudeV1_3 Model = "claude-v1.3" // An enhanced version of ClaudeV1_3 with a 100,000 token context window. ClaudeV1_3_100k Model = "claude-v1.3-100k" // An improved version of ClaudeV1, slightly improved at general helpfulness, // instruction following, coding, and other tasks. It is also considerably // better with non-English languages. ClaudeV1_2 Model = "claude-v1.2" // An earlier version of ClaudeV1. ClaudeV1_0 Model = "claude-v1.0" // Latest version of ClaudeInstantV1. It is better at a wide variety of tasks // including writing, coding, and instruction following. It performs better on // academic benchmarks, including math, reading comprehension, and coding tests. ClaudeInstantV1_1 Model = "claude-instant-v1.1" // An enhanced version of ClaudeInstantV1_1 with a 100,000 token context window. ClaudeInstantV1_1_100k Model = "claude-instant-v1.1-100k" // An earlier version of ClaudeInstantV1. ClaudeInstantV1_0 Model = "claude-instant-v1.0" )
type StreamCallback ¶
type StreamCallback func(*CompletionResponse) error
StreamCallback is a function that handles a stream of completions.
type StreamResponse ¶ added in v1.0.1
type StreamResponse struct { Completion string `json:"completion"` StopReason string `json:"stop_reason"` Model string `json:"model"` Stop string `json:"stop"` LogID string `json:"log_id"` }
StreamResponse is the response from the Anthropic API for a stream of completions.
Click to show internal directories.
Click to hide internal directories.