Documentation
¶
Index ¶
- Constants
- func AskDeepSeekStream(query string, context string, model string) (string, error)
- func ChatWithTools(systemPrompt string, history []Message, model string) (string, error)
- func FormatImageSize(bytes int64) string
- func GetToolDefinitionNames() []string
- func HandleHTTPError(resp *http.Response, spinner *ui.Spinner, providerName string) error
- func HandleNonStreamingResponse(resp *http.Response, spinner *ui.Spinner) (string, error)
- func ParseStreamingResponse(ctx context.Context, resp *http.Response, spinner *ui.Spinner, ...) (string, error)
- func StartSpinner(message string) *ui.Spinner
- func StopSpinner(spinner *ui.Spinner)
- func SupportsImages(providerName string) bool
- func ValidateChatResponse(data []byte) error
- func ValidateErrorResponse(data []byte) (string, error)
- func ValidateStreamResponse(data []byte) error
- func ValidateToolCall(toolCall interface{}) error
- func WebSearch(query string) (string, error)
- type BaseProvider
- func (b *BaseProvider) CreateAPIRequest(ctx context.Context, body interface{}) (*http.Request, error)
- func (b *BaseProvider) ExecuteRequest(req *http.Request) (*http.Response, error)
- func (b *BaseProvider) SetAPIKeyAuth(req *http.Request, headerName string)
- func (b *BaseProvider) SetBearerAuth(req *http.Request)
- type ChatRequest
- type ChatResponse
- type Choice
- type ClaudeCacheControl
- type ClaudeContent
- type ClaudeContentPart
- type ClaudeDelta
- type ClaudeImageSource
- type ClaudeMessage
- type ClaudeMultimodalMessage
- type ClaudeMultimodalRequest
- type ClaudeProvider
- func (p *ClaudeProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *ClaudeProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *ClaudeProvider) Name() string
- func (p *ClaudeProvider) SupportsImages() bool
- type ClaudeRequest
- type ClaudeResponse
- type ClaudeStreamEvent
- type ClaudeSystemBlock
- type ClaudeThinkingConfig
- type Client
- type CompactCapable
- type CompactRequest
- type CompactResponse
- type CompactUsage
- type DeepSeekProvider
- func (p *DeepSeekProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *DeepSeekProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *DeepSeekProvider) Name() string
- func (p *DeepSeekProvider) SupportsImages() bool
- type Delta
- type GeminiCandidate
- type GeminiContent
- type GeminiFunctionCall
- type GeminiFunctionCandidate
- type GeminiFunctionContent
- type GeminiFunctionDeclaration
- type GeminiFunctionPart
- type GeminiFunctionResponse
- type GeminiGenerationConfig
- type GeminiInlineData
- type GeminiMultimodalContent
- type GeminiMultimodalPart
- type GeminiMultimodalRequest
- type GeminiParameterSchema
- type GeminiPart
- type GeminiPropertyDef
- type GeminiProvider
- func (p *GeminiProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *GeminiProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *GeminiProvider) Name() string
- func (p *GeminiProvider) SetMCPEnabled(enabled bool)
- func (p *GeminiProvider) SetMCPTools(tools []GeminiFunctionDeclaration)
- func (p *GeminiProvider) SupportsImages() bool
- type GeminiRequest
- type GeminiRequestWithTools
- type GeminiResponse
- type GeminiThinkingConfig
- type GeminiToolConfig
- type GroqProvider
- func (p *GroqProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *GroqProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *GroqProvider) Name() string
- func (p *GroqProvider) SupportsImages() bool
- type ImageData
- type InputContentPart
- type InputItem
- type Message
- type MultimodalMessage
- type OllamaMessageContent
- type OllamaModel
- type OllamaProvider
- func (p *OllamaProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *OllamaProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *OllamaProvider) ListModels() ([]string, error)
- func (p *OllamaProvider) Name() string
- func (p *OllamaProvider) SupportsImages() bool
- type OllamaRequest
- type OllamaStreamResponse
- type OllamaTagsResponse
- type OpenAIContentPart
- type OpenAIImageURL
- type OpenAIMultimodalMessage
- type OpenAIMultimodalRequest
- type OpenAIProvider
- func (p *OpenAIProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, ...) (string, error)
- func (p *OpenAIProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
- func (p *OpenAIProvider) CompactHistory(ctx context.Context, input []InputItem, model, instructions string) (*CompactResponse, error)
- func (p *OpenAIProvider) Name() string
- func (p *OpenAIProvider) SupportsCompact() bool
- func (p *OpenAIProvider) SupportsImages() bool
- type Provider
- type RAGRequest
- type RAGResponse
- type RAGResult
- type ReasoningConfig
- type ResponseMetadata
- type ResponsesRequest
- type ResponsesResult
- type ResponsesStreamChunk
- type SerperResponse
- type SerperSearchRequest
- type SerperSearchResult
- type StreamChoice
- type StreamParser
- type StreamResponse
Constants ¶
const (
// MaxImageSize 最大画像サイズ: 10MB
MaxImageSize = 10 * 1024 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func AskDeepSeekStream ¶
AskDeepSeekStream は従来のストリーミング質問(後方互換) Deprecated: 後方互換性のために残されています。ChatWithTools を使用してください。
func ChatWithTools ¶
ChatWithTools はツール対応の会話を行う(ストリーミング) Deprecated: 後方互換性のために残されています。NewDeepSeekProvider + Client を使用してください。
func FormatImageSize ¶ added in v0.29.0
FormatImageSize はバイト数を人間が読みやすい形式に変換
func GetToolDefinitionNames ¶ added in v0.31.0
func GetToolDefinitionNames() []string
GetToolDefinitionNames returns all defined tool names for testing
func HandleHTTPError ¶ added in v0.31.0
HandleHTTPError はHTTPエラーレスポンスを処理
func HandleNonStreamingResponse ¶ added in v0.31.0
HandleNonStreamingResponse は非ストリーミングレスポンスを処理
func ParseStreamingResponse ¶
func ParseStreamingResponse(ctx context.Context, resp *http.Response, spinner *ui.Spinner, parser StreamParser) (string, error)
ParseStreamingResponse は共通のストリーミングレスポンス処理 コンテキストキャンセル、スピナー制御、エラーハンドリングを統一的に処理 アイドルタイムアウト方式: データ受信がない状態がN秒続くとタイムアウト ツールJSON部分は内部で記録するが表示しない
func StartSpinner ¶ added in v0.31.0
StartSpinner はスピナーを開始
func StopSpinner ¶ added in v0.31.0
StopSpinner はスピナーを停止(nilセーフ)
func SupportsImages ¶ added in v0.29.0
SupportsImages はプロバイダー名から画像対応を判定
func ValidateChatResponse ¶
ValidateChatResponse は非ストリーミングレスポンスの構造を検証
func ValidateErrorResponse ¶
ValidateErrorResponse はエラーレスポンスの構造を検証
func ValidateStreamResponse ¶
ValidateStreamResponse はストリーミングレスポンスの構造を検証
func ValidateToolCall ¶
func ValidateToolCall(toolCall interface{}) error
ValidateToolCall はツール呼び出しレスポンスの構造を検証
Types ¶
type BaseProvider ¶ added in v0.31.0
type BaseProvider struct {
ProviderName string
APIKey string
APIURL string
HTTPClient *http.Client
}
BaseProvider は各プロバイダーの共通基盤
func NewBaseProvider ¶ added in v0.31.0
func NewBaseProvider(name, apiKey, defaultURL, envURLKey string) BaseProvider
NewBaseProvider は共通のプロバイダー基盤を作成
func (*BaseProvider) CreateAPIRequest ¶ added in v0.31.0
func (b *BaseProvider) CreateAPIRequest(ctx context.Context, body interface{}) (*http.Request, error)
CreateAPIRequest はAPIリクエストを作成
func (*BaseProvider) ExecuteRequest ¶ added in v0.31.0
ExecuteRequest はHTTPリクエストを実行
func (*BaseProvider) SetAPIKeyAuth ¶ added in v0.31.0
func (b *BaseProvider) SetAPIKeyAuth(req *http.Request, headerName string)
SetAPIKeyAuth はカスタムヘッダーでAPIキー認証を設定
func (*BaseProvider) SetBearerAuth ¶ added in v0.31.0
func (b *BaseProvider) SetBearerAuth(req *http.Request)
SetBearerAuth はBearerトークン認証を設定
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Stream bool `json:"stream"`
ReasoningEffort string `json:"reasoning_effort,omitempty"` // OpenAI Extended Thinking用
}
ChatRequest はAPIリクエスト
type ChatResponse ¶
type ChatResponse struct {
Choices []Choice `json:"choices"`
}
ChatResponse は通常レスポンス
type ClaudeCacheControl ¶ added in v0.31.0
type ClaudeCacheControl struct {
Type string `json:"type"` // e.g. "ephemeral"
}
ClaudeCacheControl 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 ClaudeContent ¶
ClaudeContent はレスポンスのコンテンツ
type ClaudeContentPart ¶ added in v0.29.0
type ClaudeContentPart struct {
Type string `json:"type"` // "text" or "image"
Text string `json:"text,omitempty"` // type="text"の場合
Source *ClaudeImageSource `json:"source,omitempty"` // type="image"の場合
}
ClaudeContentPart はマルチモーダルコンテンツのパート
type ClaudeDelta ¶
ClaudeDelta はストリームの差分
type ClaudeImageSource ¶ added in v0.29.0
type ClaudeImageSource struct {
Type string `json:"type"` // "base64"
MediaType string `json:"media_type"` // "image/png", "image/jpeg" etc
Data string `json:"data"` // Base64エンコードされたデータ
}
ClaudeImageSource は画像ソース
type ClaudeMessage ¶
ClaudeMessage はClaudeのメッセージ構造
type ClaudeMultimodalMessage ¶ added in v0.29.0
type ClaudeMultimodalMessage struct {
Role string `json:"role"`
Content []ClaudeContentPart `json:"content"`
}
ClaudeMultimodalMessage はマルチモーダルメッセージ(画像含む)
type ClaudeMultimodalRequest ¶ added in v0.29.0
type ClaudeMultimodalRequest struct {
Model string `json:"model"`
Messages []interface{} `json:"messages"` // ClaudeMessage or ClaudeMultimodalMessage
// System can be either string (legacy) or []ClaudeSystemBlock (prompt caching).
System interface{} `json:"system,omitempty"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
Thinking *ClaudeThinkingConfig `json:"thinking,omitempty"`
}
ClaudeMultimodalRequest はマルチモーダルAPIリクエスト
type ClaudeProvider ¶
type ClaudeProvider struct {
// contains filtered or unexported fields
}
ClaudeProvider はClaude (Anthropic) APIのプロバイダー実装
func NewClaudeProvider ¶
func NewClaudeProvider(apiKey string) *ClaudeProvider
NewClaudeProvider は新しいClaudeProviderを作成
func (*ClaudeProvider) ChatWithImage ¶ added in v0.29.0
func (p *ClaudeProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う
func (*ClaudeProvider) ChatWithTools ¶
func (p *ClaudeProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
func (*ClaudeProvider) SupportsImages ¶ added in v0.29.0
func (p *ClaudeProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type ClaudeRequest ¶
type ClaudeRequest struct {
Model string `json:"model"`
Messages []ClaudeMessage `json:"messages"`
// System can be either string (legacy) or []ClaudeSystemBlock (prompt caching).
System interface{} `json:"system,omitempty"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
Thinking *ClaudeThinkingConfig `json:"thinking,omitempty"`
}
type ClaudeResponse ¶
type ClaudeResponse struct {
Content []ClaudeContent `json:"content"`
}
ClaudeResponse は通常レスポンス
type ClaudeStreamEvent ¶
type ClaudeStreamEvent struct {
Type string `json:"type"`
Delta ClaudeDelta `json:"delta"`
}
ClaudeStreamEvent はストリームイベント
type ClaudeSystemBlock ¶ added in v0.31.0
type ClaudeSystemBlock struct {
Type string `json:"type"` // "text"
Text string `json:"text"`
CacheControl *ClaudeCacheControl `json:"cache_control,omitempty"`
}
ClaudeSystemBlock represents a system prompt content block.
When prompt caching is enabled, we send system as an array of blocks instead of a string.
type ClaudeThinkingConfig ¶ added in v0.31.0
type ClaudeThinkingConfig struct {
Type string `json:"type"` // "enabled"
BudgetTokens int `json:"budget_tokens"` // min 1024
}
ClaudeThinkingConfig は Extended Thinking の設定
type CompactCapable ¶ added in v0.31.0
type CompactCapable interface {
// CompactHistory は会話履歴を圧縮する
CompactHistory(ctx context.Context, input []InputItem, model, instructions string) (*CompactResponse, error)
// SupportsCompact は Compact API 対応を返す
SupportsCompact() bool
}
CompactCapable は圧縮対応プロバイダーのオプショナルインターフェース 現時点では OpenAIProvider のみが実装
type CompactRequest ¶ added in v0.31.0
type CompactRequest struct {
Model string `json:"model"`
Input []InputItem `json:"input"` // フル会話ウィンドウ
Instructions string `json:"instructions,omitempty"`
}
CompactRequest は /responses/compact リクエスト
type CompactResponse ¶ added in v0.31.0
type CompactResponse struct {
Output []InputItem `json:"output"` // 圧縮済みアイテム(次の /responses に使用)
Model string `json:"model"`
Usage *CompactUsage `json:"usage,omitempty"`
}
CompactResponse は /responses/compact レスポンス
type CompactUsage ¶ added in v0.31.0
type CompactUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
}
CompactUsage はトークン使用量
type DeepSeekProvider ¶
type DeepSeekProvider struct {
// contains filtered or unexported fields
}
DeepSeekProvider はDeepSeek APIのプロバイダー実装
func NewDeepSeekProvider ¶
func NewDeepSeekProvider(apiKey string) *DeepSeekProvider
NewDeepSeekProvider は新しいDeepSeekProviderを作成
func (*DeepSeekProvider) ChatWithImage ¶ added in v0.29.0
func (p *DeepSeekProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う(非対応:テキストのみ送信)
func (*DeepSeekProvider) ChatWithTools ¶
func (p *DeepSeekProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
func (*DeepSeekProvider) SupportsImages ¶ added in v0.29.0
func (p *DeepSeekProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type GeminiCandidate ¶
type GeminiCandidate struct {
Content GeminiContent `json:"content"`
}
GeminiCandidate はレスポンスの候補
type GeminiContent ¶
type GeminiContent struct {
Parts []GeminiPart `json:"parts"`
Role string `json:"role,omitempty"` // "user" or "model"
}
GeminiContent はGeminiの contents 構造
type GeminiFunctionCall ¶ added in v0.31.0
GeminiFunctionCall - Function Call response from Gemini
type GeminiFunctionCandidate ¶ added in v0.31.0
type GeminiFunctionCandidate struct {
Content GeminiFunctionContent `json:"content"`
}
GeminiFunctionCandidate はFunction Calling対応の候補
type GeminiFunctionContent ¶ added in v0.31.0
type GeminiFunctionContent struct {
Parts []GeminiFunctionPart `json:"parts"`
Role string `json:"role,omitempty"`
}
GeminiFunctionContent はFunction Calling対応のコンテンツ
type GeminiFunctionDeclaration ¶ added in v0.31.0
type GeminiFunctionDeclaration struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters *GeminiParameterSchema `json:"parameters,omitempty"`
}
GeminiFunctionDeclaration - Gemini API用の関数宣言
func ConvertMCPToolToGeminiDeclaration ¶ added in v0.31.0
func ConvertMCPToolToGeminiDeclaration(name, description string, inputSchema json.RawMessage) GeminiFunctionDeclaration
ConvertMCPToolToGeminiDeclaration はMCPツールをGemini Function Declaration形式に変換 MCPのInputSchemaはJSON Schema形式でGeminiと互換性がある XELYON_DEBUG_GEMINI=1 でデバッグログを出力
type GeminiFunctionPart ¶ added in v0.31.0
type GeminiFunctionPart struct {
Text string `json:"text,omitempty"`
FunctionCall *GeminiFunctionCall `json:"functionCall,omitempty"`
}
GeminiFunctionPart はtext または functionCall を含むパート
type GeminiFunctionResponse ¶ added in v0.31.0
type GeminiFunctionResponse struct {
Candidates []GeminiFunctionCandidate `json:"candidates"`
}
GeminiFunctionResponse はFunction Calling対応のレスポンス
type GeminiGenerationConfig ¶ added in v0.31.0
type GeminiGenerationConfig struct {
ThinkingConfig *GeminiThinkingConfig `json:"thinkingConfig,omitempty"`
}
GeminiGenerationConfig は生成設定
type GeminiInlineData ¶ added in v0.29.0
type GeminiInlineData struct {
MimeType string `json:"mime_type"` // "image/png", "image/jpeg" etc
Data string `json:"data"` // Base64エンコードされたデータ
}
GeminiInlineData は画像データ
type GeminiMultimodalContent ¶ added in v0.29.0
type GeminiMultimodalContent struct {
Parts []GeminiMultimodalPart `json:"parts"`
Role string `json:"role,omitempty"` // "user" or "model"
}
GeminiMultimodalContent はマルチモーダル対応のcontents構造
type GeminiMultimodalPart ¶ added in v0.29.0
type GeminiMultimodalPart struct {
Text string `json:"text,omitempty"`
InlineData *GeminiInlineData `json:"inline_data,omitempty"`
}
GeminiMultimodalPart はマルチモーダル対応のparts構造
type GeminiMultimodalRequest ¶ added in v0.29.0
type GeminiMultimodalRequest struct {
Contents []interface{} `json:"contents"` // GeminiContent or GeminiMultimodalContent
}
GeminiMultimodalRequest はマルチモーダルAPIリクエスト
type GeminiParameterSchema ¶ added in v0.31.0
type GeminiParameterSchema struct {
Type string `json:"type"`
Properties map[string]GeminiPropertyDef `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
GeminiParameterSchema - パラメータスキーマ
type GeminiPart ¶
type GeminiPart struct {
Text string `json:"text"`
}
GeminiPart はGeminiの parts 構造(テキストのみ)
type GeminiPropertyDef ¶ added in v0.31.0
type GeminiPropertyDef struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
Items *GeminiPropertyDef `json:"items,omitempty"` // array型用
}
GeminiPropertyDef - プロパティ定義
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider はGemini APIのプロバイダー実装
func NewGeminiProvider ¶
func NewGeminiProvider(apiKey string) *GeminiProvider
NewGeminiProvider は新しいGeminiProviderを作成
func (*GeminiProvider) ChatWithImage ¶ added in v0.29.0
func (p *GeminiProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う
func (*GeminiProvider) ChatWithTools ¶
func (p *GeminiProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応) GEMINI_FUNCTION_CALLING=0の場合のみテキストモードを使用 MCPツールもFunction Calling経由で呼び出される
func (*GeminiProvider) SetMCPEnabled ¶ added in v0.31.0
func (p *GeminiProvider) SetMCPEnabled(enabled bool)
SetMCPEnabled はMCPが有効かどうかを設定する レガシー: 現在はMCPツールもFunction Calling経由で呼び出すため、この設定は無視される 互換性のために残している
func (*GeminiProvider) SetMCPTools ¶ added in v0.31.0
func (p *GeminiProvider) SetMCPTools(tools []GeminiFunctionDeclaration)
SetMCPTools はMCPツールの定義を設定する MCPツールはFunction Calling APIで組み込みツールと一緒に送信される
func (*GeminiProvider) SupportsImages ¶ added in v0.29.0
func (p *GeminiProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type GeminiRequest ¶
type GeminiRequest struct {
Contents []GeminiContent `json:"contents"`
}
GeminiRequest はGemini APIリクエスト
type GeminiRequestWithTools ¶ added in v0.31.0
type GeminiRequestWithTools struct {
Contents []interface{} `json:"contents"`
Tools []GeminiToolConfig `json:"tools,omitempty"`
GenerationConfig *GeminiGenerationConfig `json:"generationConfig,omitempty"`
}
GeminiRequestWithTools はtools を含むリクエスト
type GeminiResponse ¶
type GeminiResponse struct {
Candidates []GeminiCandidate `json:"candidates"`
}
GeminiResponse はGeminiレスポンス
type GeminiThinkingConfig ¶ added in v0.31.0
type GeminiThinkingConfig struct {
ThinkingBudget int `json:"thinkingBudget,omitempty"`
}
GeminiThinkingConfig は Extended Thinking の設定
type GeminiToolConfig ¶ added in v0.31.0
type GeminiToolConfig struct {
FunctionDeclarations []GeminiFunctionDeclaration `json:"function_declarations"`
}
GeminiToolConfig - API リクエスト用ツール設定
func GetCombinedToolDefinitions ¶ added in v0.31.0
func GetCombinedToolDefinitions(mcpTools []GeminiFunctionDeclaration) []GeminiToolConfig
GetCombinedToolDefinitions は組み込みツール + MCPツールの定義を返す
func GetGeminiToolDefinitions ¶ added in v0.31.0
func GetGeminiToolDefinitions() []GeminiToolConfig
GetGeminiToolDefinitions returns all tool definitions for Function Calling API
type GroqProvider ¶
type GroqProvider struct {
// contains filtered or unexported fields
}
GroqProvider はGroq APIのプロバイダー実装(OpenAI互換)
func NewGroqProvider ¶
func NewGroqProvider(apiKey string) *GroqProvider
NewGroqProvider は新しいGroqProviderを作成
func (*GroqProvider) ChatWithImage ¶ added in v0.29.0
func (p *GroqProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う(非対応:テキストのみ送信)
func (*GroqProvider) ChatWithTools ¶
func (p *GroqProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
func (*GroqProvider) SupportsImages ¶ added in v0.29.0
func (p *GroqProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type ImageData ¶ added in v0.29.0
type ImageData struct {
Path string // 元のファイルパス
MediaType string // "image/png", "image/jpeg" 等
Base64 string // Base64エンコードされた画像データ
Size int64 // ファイルサイズ(バイト)
}
ImageData は画像データを表す
type InputContentPart ¶ added in v0.31.0
type InputContentPart struct {
Type string `json:"type"` // "input_text" or "input_image"
Text string `json:"text,omitempty"` // type="input_text"の場合
ImageURL string `json:"image_url,omitempty"` // type="input_image"の場合(data:image/...形式)
}
InputContentPart は Responses API のコンテンツパート(画像対応)
type InputItem ¶ added in v0.31.0
type InputItem struct {
Type string `json:"type"` // "message" or "compacted"
Role string `json:"role,omitempty"` // "user", "assistant"
Content interface{} `json:"content,omitempty"` // string or []InputContentPart
// アシスタント応答の完全情報(Compact API用)
ID string `json:"id,omitempty"` // "msg_xxx" (アシスタント応答のID)
Status string `json:"status,omitempty"` // "completed"
// 圧縮済みアイテム用
Data string `json:"data,omitempty"` // 暗号化データ(type="compacted"の場合)
}
InputItem は Responses API の入力アイテム(Compact API対応拡張版) ユーザーメッセージ、アシスタント応答、圧縮済みアイテムを表現
func ConvertHistoryToInputItems ¶ added in v0.31.0
ConvertHistoryToInputItems は History を InputItem 形式に変換 Compact API に送信するためのフル会話ウィンドウを構築
type MultimodalMessage ¶ added in v0.29.0
type MultimodalMessage struct {
Role string `json:"role"`
Content string `json:"content"`
Image *ImageData `json:"-"` // JSON保存しない(一時的なもの)
}
MultimodalMessage は画像を含むメッセージ
func (MultimodalMessage) HasImage ¶ added in v0.29.0
func (m MultimodalMessage) HasImage() bool
HasImage は画像が添付されているか
func (MultimodalMessage) ToMessage ¶ added in v0.29.0
func (m MultimodalMessage) ToMessage() Message
ToMessage は通常のMessageに変換(画像なし)
type OllamaMessageContent ¶
type OllamaMessageContent struct {
Content string `json:"content"`
}
OllamaMessageContent はOllamaのメッセージコンテンツ
type OllamaProvider ¶
type OllamaProvider struct {
// contains filtered or unexported fields
}
OllamaProvider はOllama APIのプロバイダー実装
func NewOllamaProvider ¶
func NewOllamaProvider(baseURL string) *OllamaProvider
NewOllamaProvider は新しいOllamaProviderを作成
func (*OllamaProvider) ChatWithImage ¶ added in v0.29.0
func (p *OllamaProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う(非対応:テキストのみ送信)
func (*OllamaProvider) ChatWithTools ¶
func (p *OllamaProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
func (*OllamaProvider) ListModels ¶
func (p *OllamaProvider) ListModels() ([]string, error)
ListModels はインストール済みモデルを取得
func (*OllamaProvider) SupportsImages ¶ added in v0.29.0
func (p *OllamaProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type OllamaRequest ¶
type OllamaRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Stream bool `json:"stream"`
}
OllamaRequest はOllama APIリクエスト
type OllamaStreamResponse ¶
type OllamaStreamResponse struct {
Message OllamaMessageContent `json:"message"`
Done bool `json:"done"`
}
OllamaStreamResponse はOllamaのストリームレスポンス
type OllamaTagsResponse ¶
type OllamaTagsResponse struct {
Models []OllamaModel `json:"models"`
}
OllamaTagsResponse はモデル一覧のレスポンス
type OpenAIContentPart ¶ added in v0.29.0
type OpenAIContentPart struct {
Type string `json:"type"` // "text" or "image_url"
Text string `json:"text,omitempty"` // type="text"の場合
ImageURL *OpenAIImageURL `json:"image_url,omitempty"` // type="image_url"の場合
}
OpenAIContentPart はマルチモーダルコンテンツのパート
type OpenAIImageURL ¶ added in v0.29.0
type OpenAIImageURL struct {
URL string `json:"url"` // "data:image/png;base64,..." 形式
}
OpenAIImageURL は画像URL
type OpenAIMultimodalMessage ¶ added in v0.29.0
type OpenAIMultimodalMessage struct {
Role string `json:"role"`
Content []OpenAIContentPart `json:"content"`
}
OpenAIMultimodalMessage はマルチモーダルメッセージ
type OpenAIMultimodalRequest ¶ added in v0.29.0
type OpenAIMultimodalRequest struct {
Model string `json:"model"`
Messages []interface{} `json:"messages"` // Message or OpenAIMultimodalMessage
Stream bool `json:"stream"`
ReasoningEffort string `json:"reasoning_effort,omitempty"` // low/medium/high
}
OpenAIMultimodalRequest はマルチモーダルAPIリクエスト
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider はOpenAI APIのプロバイダー実装
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey string) *OpenAIProvider
NewOpenAIProvider は新しいOpenAIProviderを作成
func (*OpenAIProvider) ChatWithImage ¶ added in v0.29.0
func (p *OpenAIProvider) ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
ChatWithImage は画像付きメッセージで会話を行う
func (*OpenAIProvider) ChatWithTools ¶
func (p *OpenAIProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
func (*OpenAIProvider) CompactHistory ¶ added in v0.31.0
func (p *OpenAIProvider) CompactHistory(ctx context.Context, input []InputItem, model, instructions string) (*CompactResponse, error)
CompactHistory は会話履歴を Compact API で圧縮
func (*OpenAIProvider) SupportsCompact ¶ added in v0.31.0
func (p *OpenAIProvider) SupportsCompact() bool
SupportsCompact は Compact API 対応を返す
func (*OpenAIProvider) SupportsImages ¶ added in v0.29.0
func (p *OpenAIProvider) SupportsImages() bool
SupportsImages は画像入力対応を返す
type Provider ¶
type Provider interface {
// Name はプロバイダー名を返す
Name() string
// ChatWithTools はツール対応の会話を行う(ストリーミング)
ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
// SupportsImages はプロバイダーが画像入力に対応しているかを返す
SupportsImages() bool
// ChatWithImage は画像付きメッセージで会話を行う
// imageがnilまたはプロバイダーが画像非対応の場合、テキストのみで会話する
ChatWithImage(ctx context.Context, systemPrompt string, history []Message, userMessage string, image *ImageData, model string) (string, error)
}
Provider はLLMプロバイダーの共通インターフェース
func NewProvider ¶ added in v0.29.0
NewProvider はプロバイダー名から Provider インスタンスを生成
type RAGRequest ¶
type RAGResponse ¶
type ReasoningConfig ¶ added in v0.31.0
type ReasoningConfig struct {
Effort string `json:"effort,omitempty"` // low, medium, high
}
ReasoningConfig は OpenAI Extended Thinking の設定
type ResponseMetadata ¶ added in v0.31.0
type ResponseMetadata struct {
ID string `json:"id"` // "resp_xxx..."
Status string `json:"status,omitempty"` // "in_progress", "completed"
Model string `json:"model,omitempty"`
}
ResponseMetadata はレスポンスメタデータ(response.created イベント用)
type ResponsesRequest ¶ added in v0.31.0
type ResponsesRequest struct {
Model string `json:"model"`
Input interface{} `json:"input"` // string or []InputItem
Instructions string `json:"instructions,omitempty"` // システムプロンプト
Stream bool `json:"stream,omitempty"`
Reasoning *ReasoningConfig `json:"reasoning,omitempty"` // Extended Thinking
}
ResponsesRequest は Responses API リクエスト
type ResponsesResult ¶ added in v0.31.0
type ResponsesResult struct {
Content string // テキストコンテンツ
ResponseID string // レスポンスID(response.created から取得)
}
ResponsesResult は Responses API のレスポンス結果(ID付き)
type ResponsesStreamChunk ¶ added in v0.31.0
type ResponsesStreamChunk struct {
Type string `json:"type"` // "response.output_text.delta", "response.created", etc.
Delta string `json:"delta,omitempty"` // テキスト差分
Response *ResponseMetadata `json:"response,omitempty"` // response.created で取得
}
ResponsesStreamChunk は Responses API ストリーミングチャンク
type SerperResponse ¶
type SerperResponse struct {
Organic []SerperSearchResult `json:"organic"`
}
SerperResponse は Serper API のレスポンス構造
type SerperSearchRequest ¶
type SerperSearchRequest struct {
Q string `json:"q"`
Gl string `json:"gl,omitempty"` // 地域コード (optional)
Hl string `json:"hl,omitempty"` // 言語コード (optional)
}
SerperSearchRequest は Serper API へのリクエスト構造
type SerperSearchResult ¶
type SerperSearchResult struct {
Title string `json:"title"`
Link string `json:"link"`
Snippet string `json:"snippet"`
}
SerperSearchResult は検索結果の1件
type StreamParser ¶
StreamParser はストリーミングレスポンスの1行をパースする関数型 戻り値: (content string, done bool, err error)
- content: この行から抽出されたテキストコンテンツ
- done: ストリームの終了を示すフラグ
- err: パースエラー
type StreamResponse ¶
type StreamResponse struct {
Choices []StreamChoice `json:"choices"`
}
StreamResponse はストリームレスポンス