anthropic

package
v1.13.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 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,
	},
	"completion": {
		"claude-instant": 2.4,
		"claude":         24,
	},
}

Functions

This section is empty.

Types

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) 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 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