claude

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelToBudgetTokens

func LevelToBudgetTokens(level string) int

LevelToBudgetTokens は api.LevelToBudgetTokens のエイリアス(後方互換)

Types

type CacheControl

type CacheControl struct {
	Type string `json:"type"` // e.g. "ephemeral"
}

CacheControl enables prompt caching for a content block.

This is gated by config.PromptCache.Enabled and disabled by default. If the upstream schema changes, requests may fail; keep the feature optional.

type Content

type Content struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

Content はレスポンスのコンテンツ

type ContentPart

type ContentPart struct {
	Type   string       `json:"type"`             // "text" or "image"
	Text   string       `json:"text,omitempty"`   // type="text"の場合
	Source *ImageSource `json:"source,omitempty"` // type="image"の場合
}

ContentPart はマルチモーダルコンテンツのパート

type Delta

type Delta struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

Delta はストリームの差分

type ImageSource

type ImageSource struct {
	Type      string `json:"type"`       // "base64"
	MediaType string `json:"media_type"` // "image/png", "image/jpeg" etc
	Data      string `json:"data"`       // Base64エンコードされたデータ
}

ImageSource は画像ソース

type Message

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

Message はClaudeのメッセージ構造

type MultimodalMessage

type MultimodalMessage struct {
	Role    string        `json:"role"`
	Content []ContentPart `json:"content"`
}

MultimodalMessage はマルチモーダルメッセージ(画像含む)

type MultimodalRequest

type MultimodalRequest struct {
	Model    string        `json:"model"`
	Messages []interface{} `json:"messages"` // Message or MultimodalMessage
	// System can be either string (legacy) or []SystemBlock (prompt caching).
	System    interface{}     `json:"system,omitempty"`
	MaxTokens int             `json:"max_tokens"`
	Stream    bool            `json:"stream"`
	Thinking  *ThinkingConfig `json:"thinking,omitempty"`
}

MultimodalRequest はマルチモーダルAPIリクエスト

type Provider

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

Provider はClaude (Anthropic) APIのプロバイダー実装

func New

func New(apiKey string) *Provider

New は新しいProviderを作成

func (*Provider) ChatWithImage

func (p *Provider) ChatWithImage(ctx context.Context, systemPrompt string, history []api.Message, userMessage string, image *api.ImageData, model string) (string, error)

ChatWithImage は画像付きメッセージで会話を行う

func (*Provider) ChatWithTools

func (p *Provider) ChatWithTools(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)

ChatWithTools は Provider interface の実装(context対応)

func (*Provider) Name

func (p *Provider) Name() string

Name はプロバイダー名を返す

func (*Provider) SupportsImages

func (p *Provider) SupportsImages() bool

SupportsImages は画像入力対応を返す

type Request

type Request struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
	// System can be either string (legacy) or []SystemBlock (prompt caching).
	System    interface{}     `json:"system,omitempty"`
	MaxTokens int             `json:"max_tokens"`
	Stream    bool            `json:"stream"`
	Thinking  *ThinkingConfig `json:"thinking,omitempty"`
}

type Response

type Response struct {
	Content []Content `json:"content"`
}

Response は通常レスポンス

type StreamEvent

type StreamEvent struct {
	Type  string `json:"type"`
	Delta Delta  `json:"delta"`
}

StreamEvent はストリームイベント

type SystemBlock

type SystemBlock struct {
	Type         string        `json:"type"` // "text"
	Text         string        `json:"text"`
	CacheControl *CacheControl `json:"cache_control,omitempty"`
}

SystemBlock represents a system prompt content block.

When prompt caching is enabled, we send system as an array of blocks instead of a string.

type ThinkingConfig

type ThinkingConfig struct {
	Type         string `json:"type"`          // "enabled"
	BudgetTokens int    `json:"budget_tokens"` // min 1024
}

ThinkingConfig は Extended Thinking の設定

Jump to

Keyboard shortcuts

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