Documentation ¶
Index ¶
- Constants
- type Anthropic
- func (a *Anthropic) ChatCompletion(conversation ai.BotConversation, opts ...ai.LanguageModelOption) (*ai.TextStreamResult, error)
- func (a *Anthropic) ChatCompletionNoStream(conversation ai.BotConversation, opts ...ai.LanguageModelOption) (string, error)
- func (a *Anthropic) CountTokens(text string) int
- func (a *Anthropic) GetDefaultConfig() ai.LLMConfig
- func (a *Anthropic) TokenLimit() int
- type Client
- type Content
- type InputMessage
- type MessageRequest
- type MessageStreamEvent
- type OutputMessage
- type RequestMetadata
- type StreamDelta
- type Usage
Constants ¶
View Source
const ( MessageEndpoint = "https://api.anthropic.com/v1/messages" APIKeyHeader = "X-API-Key" //nolint:gosec StopReasonStopSequence = "stop_sequence" StopReasonMaxTokens = "max_tokens" )
View Source
const DefaultMaxTokens = 4096
View Source
const RoleAssistant = "assistant"
View Source
const RoleUser = "user"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anthropic ¶
type Anthropic struct {
// contains filtered or unexported fields
}
func New ¶
func New(llmService ai.ServiceConfig) *Anthropic
func (*Anthropic) ChatCompletion ¶
func (a *Anthropic) ChatCompletion(conversation ai.BotConversation, opts ...ai.LanguageModelOption) (*ai.TextStreamResult, error)
func (*Anthropic) ChatCompletionNoStream ¶
func (a *Anthropic) ChatCompletionNoStream(conversation ai.BotConversation, opts ...ai.LanguageModelOption) (string, error)
func (*Anthropic) CountTokens ¶ added in v0.4.0
func (*Anthropic) GetDefaultConfig ¶
func (*Anthropic) TokenLimit ¶ added in v0.4.0
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) MessageCompletion ¶ added in v0.6.1
func (c *Client) MessageCompletion(completionRequest MessageRequest) (*ai.TextStreamResult, error)
func (*Client) MessageCompletionNoStream ¶ added in v0.6.1
func (c *Client) MessageCompletionNoStream(completionRequest MessageRequest) (string, error)
type InputMessage ¶ added in v0.6.1
type MessageRequest ¶ added in v0.6.1
type MessageRequest struct { Model string `json:"model"` Messages []InputMessage `json:"messages"` System string `json:"system"` MaxTokens int `json:"max_tokens"` Metadata RequestMetadata `json:"metadata"` Stream bool `json:"stream"` }
type MessageStreamEvent ¶ added in v0.6.1
type MessageStreamEvent struct { Type string `json:"type"` Message OutputMessage Index int `json:"index"` ContentBlock StreamDelta `json:"content_block"` Delta StreamDelta `json:"delta"` }
type OutputMessage ¶ added in v0.6.1
type RequestMetadata ¶ added in v0.6.1
type RequestMetadata struct {
UserID string `json:"user_id"`
}
type StreamDelta ¶ added in v0.6.1
Click to show internal directories.
Click to hide internal directories.