anthropic

package
v0.0.0-...-228a020 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Models = map[string]ModelConfig{
	"ClaudeOpus4": {
		Name:           "claude-opus-4-20250514",
		SupportsVision: true,
		MaxTokens:      64000,
		Description:    "Claude Opus 4 is the latest model with advanced capabilities and a large context window.",
	},
	"ClaudeSonnet4": {
		Name:           "claude-sonnet-4-20250514",
		SupportsVision: true,
		MaxTokens:      64000,
		Description:    "Claude Sonnet 4 is designed for complex reasoning tasks with a large context window.",
	},
	"ClaudeSonnet3_7": {
		Name:           "claude-3-7-sonnet-20250219",
		SupportsVision: true,
		MaxTokens:      64000,
		Description:    "Claude Sonnet 3.7 is optimized for advanced reasoning and complex tasks.",
	},
	"ClaudeSonnet3_5": {
		Name:           "claude-3-5-sonnet-20241022",
		SupportsVision: true,
		MaxTokens:      64000,
		Description:    "Claude Sonnet 3.5 (New) is a versatile model with enhanced capabilities for various tasks.",
	},
	"ClaudeHaiku3_5": {
		Name:           "claude-3-5-haiku-20241022",
		SupportsVision: true,
		MaxTokens:      64000,
		Description:    "Claude Haiku 3.5 is designed for tasks requiring concise and efficient responses.",
	},
}

Functions

func Authenticate

func Authenticate() (token string, err error)

func Completion

func Completion(ctx context.Context, token string, model ModelConfig, prompt Prompt) (io.Reader, error)

Types

type Anthropic

type Anthropic struct {
	Token string
	Model ModelConfig
}

func NewAnthropic

func NewAnthropic(token string) *Anthropic

type ChatMessage

type ChatMessage struct {
	Role  Role        `json:"role"`
	Parts MessagePart `json:"parts"`
}

type DataKind

type DataKind int

DataKind represents the type of data contained in the []byte

const (
	DataKindUnknown DataKind = iota
	DataKindImage
	DataKindText
)

type ImagePayload

type ImagePayload struct {
	Type   string `json:"type"`
	Source struct {
		Type      string `json:"type"`
		MediaType string `json:"media_type"`
		Data      string `json:"data"`
	} `json:"source"`
}

type Message

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

type MessagePart

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

type ModelConfig

type ModelConfig struct {
	Provider       string
	Name           string
	SupportsVision bool
	Description    string
	MaxTokens      int
}

type Prompt

type Prompt interface {
	GetPurpose() string
	GetHistory() ([]string, []string)
	GetQuestion() string
	GetReferences() [][]byte
}

type Role

type Role string
var (
	User Role = "USER"
	Bot  Role = "ASSISTANT"
)

Jump to

Keyboard shortcuts

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