Documentation
¶
Index ¶
- func ConvertToolUseToToolJSON(id, name string, input map[string]interface{}) (string, error)
- func GetToolDefinitionNames() []string
- func LevelToBudgetTokens(level string) int
- type CacheControl
- type ClaudeTool
- type Content
- type ContentBlock
- type ContentPart
- type Delta
- type ImageSource
- type Message
- type MultimodalMessage
- type MultimodalRequest
- type Provider
- func (p *Provider) ChatWithImage(ctx context.Context, systemPrompt string, history []api.Message, ...) (string, error)
- func (p *Provider) ChatWithTools(ctx context.Context, systemPrompt string, history []api.Message, model string) (string, error)
- func (p *Provider) IsFunctionCallingEnabled() bool
- func (p *Provider) Name() string
- func (p *Provider) SetMCPTools(tools []api.OpenAIToolFunction)
- func (p *Provider) SetUsageCallback(callback api.UsageCallback)
- func (p *Provider) SupportsImages() bool
- type Request
- type Response
- type StreamEvent
- type StreamUsage
- type SystemBlock
- type ThinkingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToolUseToToolJSON ¶ added in v0.44.0
ConvertToolUseToToolJSON は Claude の tool_use を内部JSON形式に変換 Returns: {"id": "toolu_01ABC...", "tool": "read_file", "args": {"path": "/path/to/file"}}
func GetToolDefinitionNames ¶ added in v0.44.0
func GetToolDefinitionNames() []string
GetToolDefinitionNames は定義済みツール名一覧を返す(テスト用)
func LevelToBudgetTokens ¶
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 ClaudeTool ¶ added in v0.44.0
type ClaudeTool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema map[string]interface{} `json:"input_schema"`
}
ClaudeTool は Anthropic Claude API 用のツール定義 OpenAI とは異なり、フラットな構造で input_schema を使用
func ConvertOpenAIToolToClaude ¶ added in v0.44.0
func ConvertOpenAIToolToClaude(tool api.OpenAIToolFunction) ClaudeTool
ConvertOpenAIToolToClaude は OpenAI 形式のツールを Claude 形式に変換する
func GetClaudeToolDefinitions ¶ added in v0.44.0
func GetClaudeToolDefinitions() []ClaudeTool
GetClaudeToolDefinitions は組み込みツール定義を Claude 形式で返す ToolRegistry から自動生成
func GetCombinedClaudeTools ¶ added in v0.44.0
func GetCombinedClaudeTools(mcpTools []api.OpenAIToolFunction) []ClaudeTool
GetCombinedClaudeTools は組み込みツール + MCPツールを返す 重複するツール名がある場合は最初に登録されたものを優先
type Content ¶
type Content struct {
Type string `json:"type"` // "text" or "tool_use"
Text string `json:"text,omitempty"` // text 用
ID string `json:"id,omitempty"` // tool_use 用
Name string `json:"name,omitempty"` // tool_use 用
Input map[string]interface{} `json:"input,omitempty"` // tool_use 用
}
Content はレスポンスのコンテンツ
type ContentBlock ¶ added in v0.44.0
type ContentBlock struct {
Type string `json:"type"` // "text" or "tool_use"
ID string `json:"id,omitempty"` // tool_use 用
Name string `json:"name,omitempty"` // tool_use 用
Text string `json:"text,omitempty"` // text 用
Input map[string]interface{} `json:"input,omitempty"` // tool_use 用(非ストリーミング)
}
ContentBlock はストリーミングのコンテンツブロック (content_block_start 用)
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,omitempty"`
PartialJSON string `json:"partial_json,omitempty"` // tool_use の input (input_json_delta)
StopReason string `json:"stop_reason,omitempty"` // message_delta 用
}
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 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"`
Tools []ClaudeTool `json:"tools,omitempty"` // Tool Use用
}
MultimodalRequest はマルチモーダルAPIリクエスト
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider はClaude (Anthropic) APIのプロバイダー実装
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) IsFunctionCallingEnabled ¶ added in v0.46.0
IsFunctionCallingEnabled は Function Calling が有効かを返す
func (*Provider) SetMCPTools ¶ added in v0.44.0
func (p *Provider) SetMCPTools(tools []api.OpenAIToolFunction)
SetMCPTools は MCP ツール定義を設定する(Tool Use用)
func (*Provider) SetUsageCallback ¶ added in v0.46.0
func (p *Provider) SetUsageCallback(callback api.UsageCallback)
SetUsageCallback は使用量レポートのコールバックを設定する
func (*Provider) SupportsImages ¶
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"`
Tools []ClaudeTool `json:"tools,omitempty"` // Tool Use用
}
type Response ¶
type Response struct {
Content []Content `json:"content"`
StopReason string `json:"stop_reason,omitempty"` // "end_turn", "tool_use" など
}
Response は通常レスポンス
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Index int `json:"index,omitempty"`
ContentBlock *ContentBlock `json:"content_block,omitempty"` // content_block_start 用
Delta *Delta `json:"delta,omitempty"`
Usage *StreamUsage `json:"usage,omitempty"` // message_delta 用
}
StreamEvent はストリームイベント
type StreamUsage ¶ added in v0.46.0
type StreamUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CacheReadInputTokens int `json:"cache_read_input_tokens,omitempty"`
CacheCreationInputTokens int `json:"cache_creation_input_tokens,omitempty"`
}
StreamUsage は Claude のトークン使用量
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 の設定