miniclaude

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelClaude3Opus   = "claude-3-opus-20240229"
	ModelClaude3Sonnet = "claude-3-sonnet-20240229"
	ModelClaude3Haiku  = "claude-3-haiku-20240307"

	// legacy models
	ModelClaude21        = "claude-2.1"
	ModelClaudeInstant12 = "claude-instant-1.2"
)
View Source
const (
	StopReasonMaxTokens    string = "max_tokens"
	StopReasonStopSequence string = "stop_sequence"
	StopReasonEndTurn      string = "end_turn"
)
View Source
const (
	ContentTypeText  string = "text"
	ContentTypeImage string = "image"
)
View Source
const (
	ContentBlockMediaTypeImagePng  string = "image/png"
	ContentBlockMediaTypeImageJpeg string = "image/jpeg"
	ContentBlockMediaTypeImageGif  string = "image/gif"
	ContentBlockMediaTypeImageWebp string = "image/webp"
)
View Source
const (
	RoleUser      string = "user"
	RoleAssistant string = "assistant"
)

Variables

View Source
var (
	ModelAliases = map[string]string{
		"opus":   ModelClaude3Opus,
		"sonnet": ModelClaude3Sonnet,
		"haiku":  ModelClaude3Haiku,
	}

	BaseURL                  = "https://api.anthropic.com"
	APIVersion               = "2023-06-01"
	DefaultMaxTokensToSample = 1200
)

Functions

This section is empty.

Types

type ContentBlock added in v1.15.0

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
	// Source is only present if the type is "image"
	Source *ContentBlockSource `json:"source,omitempty"`
}

type ContentBlockSource added in v1.15.0

type ContentBlockSource struct {
	Type      string `json:"type"` // always "base64"
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
}

type ErrorBlock added in v1.15.0

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

type Message added in v1.15.0

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

type MessagesRequest added in v1.15.0

type MessagesRequest struct {
	Model     string    `json:"model"`
	Messages  []Message `json:"messages"`
	System    string    `json:"system,omitempty"`
	MaxTokens int       `json:"max_tokens"`
	Stream    bool      `json:"stream,omitempty"`
}

type MessagesResponse added in v1.15.0

type MessagesResponse struct {
	ID           string         `json:"id"`
	Type         string         `json:"type"` // always "message"
	Error        ErrorBlock     `json:"error,omitempty"`
	Role         string         `json:"role"` // always "assistant"
	Content      []ContentBlock `json:"content"`
	Model        string         `json:"model"`
	StopReason   string         `json:"stop_reason"`
	StopSequence string         `json:"stop_sequence,omitempty"`
	Usage        Usage          `json:"usage"`
}

type Request added in v1.15.0

type Request struct {
	HTTPClient *http.Client
	C          chan string
	Endpoint   string
	APIKey     string
	APIVersion string
}

func NewMessagesRequest added in v1.15.0

func NewMessagesRequest() *Request

func (*Request) Stream added in v1.15.0

func (c *Request) Stream(mr *MessagesRequest) error

type Usage added in v1.15.0

type Usage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

Jump to

Keyboard shortcuts

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