Documentation
¶
Index ¶
- func AskDeepSeekStream(query string, context string, model string) (string, error)
- func ChatWithTools(systemPrompt string, history []Message, model string) (string, error)
- func ParseStreamingResponse(ctx context.Context, resp *http.Response, spinner *ui.Spinner, ...) (string, error)
- 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 ChatRequest
- type ChatResponse
- type Choice
- type ClaudeContent
- type ClaudeDelta
- type ClaudeMessage
- type ClaudeProvider
- type ClaudeRequest
- type ClaudeResponse
- type ClaudeStreamEvent
- type Client
- type DeepSeekProvider
- type Delta
- type GeminiCandidate
- type GeminiContent
- type GeminiPart
- type GeminiProvider
- type GeminiRequest
- type GeminiResponse
- type GroqProvider
- type Message
- type OllamaMessageContent
- type OllamaModel
- type OllamaProvider
- type OllamaRequest
- type OllamaStreamResponse
- type OllamaTagsResponse
- type OpenAIProvider
- type Provider
- type RAGRequest
- type RAGResponse
- type RAGResult
- type SerperResponse
- type SerperSearchRequest
- type SerperSearchResult
- type StreamChoice
- type StreamParser
- type StreamResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AskDeepSeekStream ¶
AskDeepSeekStream は従来のストリーミング質問(後方互換) Deprecated: 後方互換性のために残されています。ChatWithTools を使用してください。
func ChatWithTools ¶
ChatWithTools はツール対応の会話を行う(ストリーミング) Deprecated: 後方互換性のために残されています。NewDeepSeekProvider + Client を使用してください。
func ParseStreamingResponse ¶
func ParseStreamingResponse(ctx context.Context, resp *http.Response, spinner *ui.Spinner, parser StreamParser) (string, error)
ParseStreamingResponse は共通のストリーミングレスポンス処理 コンテキストキャンセル、スピナー制御、エラーハンドリングを統一的に処理
func ValidateChatResponse ¶
ValidateChatResponse は非ストリーミングレスポンスの構造を検証
func ValidateErrorResponse ¶
ValidateErrorResponse はエラーレスポンスの構造を検証
func ValidateStreamResponse ¶
ValidateStreamResponse はストリーミングレスポンスの構造を検証
func ValidateToolCall ¶
func ValidateToolCall(toolCall interface{}) error
ValidateToolCall はツール呼び出しレスポンスの構造を検証
Types ¶
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Stream bool `json:"stream"`
}
ChatRequest はAPIリクエスト
type ChatResponse ¶
type ChatResponse struct {
Choices []Choice `json:"choices"`
}
ChatResponse は通常レスポンス
type ClaudeContent ¶
ClaudeContent はレスポンスのコンテンツ
type ClaudeDelta ¶
ClaudeDelta はストリームの差分
type ClaudeMessage ¶
ClaudeMessage はClaudeのメッセージ構造
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) ChatWithTools ¶
func (p *ClaudeProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
type ClaudeRequest ¶
type ClaudeRequest struct {
Model string `json:"model"`
Messages []ClaudeMessage `json:"messages"`
System string `json:"system,omitempty"`
MaxTokens int `json:"max_tokens"`
Stream bool `json:"stream"`
}
ClaudeRequest はClaude APIリクエスト
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 DeepSeekProvider ¶
type DeepSeekProvider struct {
// contains filtered or unexported fields
}
DeepSeekProvider はDeepSeek APIのプロバイダー実装
func NewDeepSeekProvider ¶
func NewDeepSeekProvider(apiKey string) *DeepSeekProvider
NewDeepSeekProvider は新しいDeepSeekProviderを作成
func (*DeepSeekProvider) ChatWithTools ¶
func (p *DeepSeekProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
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 GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider はGemini APIのプロバイダー実装
func NewGeminiProvider ¶
func NewGeminiProvider(apiKey string) *GeminiProvider
NewGeminiProvider は新しいGeminiProviderを作成
func (*GeminiProvider) ChatWithTools ¶
func (p *GeminiProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
type GeminiRequest ¶
type GeminiRequest struct {
Contents []GeminiContent `json:"contents"`
}
GeminiRequest はGemini APIリクエスト
type GeminiResponse ¶
type GeminiResponse struct {
Candidates []GeminiCandidate `json:"candidates"`
}
GeminiResponse はGeminiレスポンス
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) ChatWithTools ¶
func (p *GroqProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
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) 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 はインストール済みモデルを取得
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 OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider はOpenAI APIのプロバイダー実装
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey string) *OpenAIProvider
NewOpenAIProvider は新しいOpenAIProviderを作成
func (*OpenAIProvider) ChatWithTools ¶
func (p *OpenAIProvider) ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
ChatWithTools は Provider interface の実装(context対応)
type Provider ¶
type Provider interface {
// Name はプロバイダー名を返す
Name() string
// ChatWithTools はツール対応の会話を行う(ストリーミング)
ChatWithTools(ctx context.Context, systemPrompt string, history []Message, model string) (string, error)
}
Provider はLLMプロバイダーの共通インターフェース
type RAGRequest ¶
type RAGResponse ¶
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 はストリームレスポンス