anthropic

package
v1.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnthropicPerMillionTokenCost = map[string]map[string]float64{
	"prompt": {
		"claude-instant":    0.8,
		"claude":            8,
		"claude-3-opus":     15,
		"claude-3-sonnet":   3,
		"claude-3.5-sonnet": 3,
		"claude-3.5-haiku":  1,
		"claude-3-haiku":    0.25,
	},
	"completion": {
		"claude-instant":    2.4,
		"claude":            24,
		"claude-3-opus":     75,
		"claude-3-sonnet":   15,
		"claude-3.5-sonnet": 15,
		"claude-3.5-haiku":  5,
		"claude-3-haiku":    1.25,
	},
}

Functions

This section is empty.

Types

type BedrockCompletionRequest added in v1.36.0

type BedrockCompletionRequest struct {
	Prompt            string   `json:"prompt"`
	MaxTokensToSample int      `json:"max_tokens_to_sample"`
	StopSequences     []string `json:"stop_sequences,omitempty"`
	Temperature       float32  `json:"temperature,omitempty"`
	TopP              int      `json:"top_p,omitempty"`
	TopK              int      `json:"top_k,omitempty"`
}

type BedrockCompletionResponse added in v1.36.0

type BedrockCompletionResponse struct {
	Completion string          `json:"completion"`
	StopReason string          `json:"stop_reason"`
	Model      string          `json:"model"`
	Metrics    *BedrockMetrics `json:"amazon-bedrock-invocationMetrics"`
}

type BedrockMessageRequest added in v1.36.0

type BedrockMessageRequest struct {
	AnthropicVersion string    `json:"anthropic_version"`
	Messages         []Message `json:"messages"`
	MaxTokens        int       `json:"max_tokens"`
	StopSequences    []string  `json:"stop_sequences,omitempty"`
	Temperature      float32   `json:"temperature,omitempty"`
	TopP             int       `json:"top_p,omitempty"`
	TopK             int       `json:"top_k,omitempty"`
	Metadata         *Metadata `json:"metadata,omitempty"`
}

type BedrockMessageType added in v1.36.0

type BedrockMessageType struct {
	Type string `json:"type"`
}

type BedrockMessagesStopResponse added in v1.36.0

type BedrockMessagesStopResponse struct {
	Type    string          `json:"type"`
	Metrics *BedrockMetrics `json:"amazon-bedrock-invocationMetrics"`
}

type BedrockMetrics added in v1.36.0

type BedrockMetrics struct {
	InputTokenCount   int `json:"inputTokenCount"`
	OutputTokenCount  int `json:"outputTokenCount"`
	InvocationLatency int `json:"invocationLatency"`
	FirstByteLatency  int `json:"firstByteLatency"`
}

type CompletionRequest

type CompletionRequest struct {
	Model             string    `json:"model"`
	Prompt            string    `json:"prompt"`
	MaxTokensToSample int       `json:"max_tokens_to_sample"`
	StopSequences     []string  `json:"stop_sequences,omitempty"`
	Temperature       float32   `json:"temperature,omitempty"`
	TopP              int       `json:"top_p,omitempty"`
	TopK              int       `json:"top_k,omitempty"`
	Metadata          *Metadata `json:"metadata,omitempty"`
	Stream            bool      `json:"stream,omitempty"`
}

type CompletionResponse

type CompletionResponse struct {
	Completion string `json:"completion"`
	StopReason string `json:"stop_reason"`
	Model      string `json:"model"`
}

type CostEstimator

type CostEstimator struct {
	// contains filtered or unexported fields
}

func NewCostEstimator

func NewCostEstimator(tc tokenCounter) *CostEstimator

func (*CostEstimator) Count

func (ce *CostEstimator) Count(input string) int

func (*CostEstimator) CountMessagesTokens added in v1.14.0

func (ce *CostEstimator) CountMessagesTokens(messages []Message) int

func (*CostEstimator) EstimateCompletionCost

func (ce *CostEstimator) EstimateCompletionCost(model string, tks int) (float64, error)

func (*CostEstimator) EstimatePromptCost

func (ce *CostEstimator) EstimatePromptCost(model string, tks int) (float64, error)

func (*CostEstimator) EstimateTotalCost

func (ce *CostEstimator) EstimateTotalCost(model string, promptTks, completionTks int) (float64, error)

type Error

type Error struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

type ErrorResponse

type ErrorResponse struct {
	Error *Error `json:"error"`
}

type Message added in v1.14.0

type Message struct {
	Content string `json:"content"`
	Role    string `json:"role"`
}

type MessageResponseContent added in v1.14.0

type MessageResponseContent struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type MessagesRequest added in v1.14.0

type MessagesRequest struct {
	Model         string    `json:"model"`
	Messages      []Message `json:"messages"`
	MaxTokens     int       `json:"max_tokens"`
	StopSequences []string  `json:"stop_sequences,omitempty"`
	Temperature   float32   `json:"temperature,omitempty"`
	TopP          int       `json:"top_p,omitempty"`
	TopK          int       `json:"top_k,omitempty"`
	Metadata      *Metadata `json:"metadata,omitempty"`
	Stream        bool      `json:"stream,omitempty"`
}

type MessagesResponse added in v1.14.0

type MessagesResponse struct {
	Id           string                   `json:"id"`
	Type         string                   `json:"type"`
	Role         string                   `json:"role"`
	Content      []MessageResponseContent `json:"content"`
	Model        string                   `json:"model"`
	StopReason   string                   `json:"stop_reason"`
	StopSequence string                   `json:"stop_sequence,omitempty"`
	Usage        struct {
		InputTokens  int `json:"input_tokens"`
		OutputTokens int `json:"output_tokens"`
	}
}

type MessagesStreamBlockDelta added in v1.14.0

type MessagesStreamBlockDelta struct {
	Index int                    `json:"index"`
	Delta MessageResponseContent `json:"delta"`
}

type MessagesStreamBlockStart added in v1.14.0

type MessagesStreamBlockStart struct {
	Index        int                    `json:"index"`
	ContentBlock MessageResponseContent `json:"content_block"`
}

type MessagesStreamBlockStop added in v1.14.0

type MessagesStreamBlockStop struct {
	Index int `json:"index"`
}

type MessagesStreamMessageDelta added in v1.14.0

type MessagesStreamMessageDelta struct {
	Delta struct {
		StopReason   string `json:"stop_reason"`
		StopSequence string `json:"stop_sequence,omitempty"`
	} `json:"delta"`

	Usage struct {
		OutputTokens int `json:"output_tokens"`
	} `json:"usage"`
}

type MessagesStreamMessageStart added in v1.14.0

type MessagesStreamMessageStart struct {
	Message MessagesResponse `json:"message"`
}

type MessagesStreamMessageStop added in v1.14.0

type MessagesStreamMessageStop struct {
	Type string `json:"type"`
}

type Metadata

type Metadata struct {
	UserId string `json:"user_id"`
}

type TokenCounter

type TokenCounter struct {
	// contains filtered or unexported fields
}

func NewTokenCounter

func NewTokenCounter() (*TokenCounter, error)

func (*TokenCounter) Count

func (tc *TokenCounter) Count(input string) int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL