provider

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultShouldThinkFn

func DefaultShouldThinkFn(s string) bool

Types

type AnthropicClient

type AnthropicClient ProviderClient

type AnthropicOption

type AnthropicOption func(*anthropicOptions)

func WithAnthropicBedrock

func WithAnthropicBedrock(useBedrock bool) AnthropicOption

func WithAnthropicDisableCache

func WithAnthropicDisableCache() AnthropicOption

func WithAnthropicReasoningEffort

func WithAnthropicReasoningEffort(effort string) AnthropicOption

func WithAnthropicShouldThinkFn

func WithAnthropicShouldThinkFn(fn func(string) bool) AnthropicOption

func WithVertexAI

func WithVertexAI(projectID, localtion string, localForCounting string) AnthropicOption

type BedrockClient

type BedrockClient ProviderClient

type BedrockOption

type BedrockOption func(*bedrockOptions)

type DeepSeekClient

type DeepSeekClient ProviderClient

type DeepSeekOption

type DeepSeekOption func(*deepSeekOptions)

func WithDeepSeekBaseURL

func WithDeepSeekBaseURL(baseURL string) DeepSeekOption

func WithDeepSeekExtraHeaders

func WithDeepSeekExtraHeaders(headers map[string]string) DeepSeekOption

type EventType

type EventType string
const (
	EventContentStart  EventType = "content_start"
	EventToolUseStart  EventType = "tool_use_start"
	EventToolUseDelta  EventType = "tool_use_delta"
	EventToolUseStop   EventType = "tool_use_stop"
	EventContentDelta  EventType = "content_delta"
	EventThinkingDelta EventType = "thinking_delta"
	EventContentStop   EventType = "content_stop"
	EventComplete      EventType = "complete"
	EventError         EventType = "error"
	EventWarning       EventType = "warning"
)

type GeminiClient

type GeminiClient ProviderClient

type GeminiOption

type GeminiOption func(*geminiOptions)

func WithGeminiDisableCache

func WithGeminiDisableCache() GeminiOption

type OpenAIClient

type OpenAIClient ProviderClient

type OpenAIOption

type OpenAIOption func(*openaiOptions)

func WithOpenAIBaseURL

func WithOpenAIBaseURL(baseURL string) OpenAIOption

func WithOpenAIDisableCache

func WithOpenAIDisableCache() OpenAIOption

func WithOpenAIExtraHeaders

func WithOpenAIExtraHeaders(headers map[string]string) OpenAIOption

func WithReasoningEffort

func WithReasoningEffort(effort string) OpenAIOption

type Provider

type Provider interface {
	SendMessages(ctx context.Context, messages []message.Message, tools []tools.BaseTool) (*ProviderResponse, error)

	StreamResponse(ctx context.Context, messages []message.Message, tools []tools.BaseTool) <-chan ProviderEvent

	Model() models.Model

	// Counts tokens for provided messages using underlying client OR fallback to default estimation strategy,
	// returns tokens count and whether a threshold has been hit based on the model context size,
	// threshold can be used to track an approaching limit to trigger compaction or other activities
	CountTokens(ctx context.Context, threshold float64, messages []message.Message, tools []toolsPkg.BaseTool) (tokens int64, hit bool)

	// Calculates and sets new max_tokens if needed to be used by underlying client
	AdjustMaxTokens(estimatedTokens int64) int64
}

func NewProvider

func NewProvider(providerName models.ModelProvider, opts ...ProviderClientOption) (Provider, error)

type ProviderClient

type ProviderClient interface {
	// contains filtered or unexported methods
}

type ProviderClientOption

type ProviderClientOption func(*providerClientOptions)

func WithAPIKey

func WithAPIKey(apiKey string) ProviderClientOption

func WithAnthropicOptions

func WithAnthropicOptions(anthropicOptions ...AnthropicOption) ProviderClientOption

func WithBaseURL

func WithBaseURL(baseURL string) ProviderClientOption

func WithBedrockOptions

func WithBedrockOptions(bedrockOptions ...BedrockOption) ProviderClientOption

func WithDeepSeekOptions

func WithDeepSeekOptions(deepSeekOptions ...DeepSeekOption) ProviderClientOption

func WithGeminiOptions

func WithGeminiOptions(geminiOptions ...GeminiOption) ProviderClientOption

func WithHeaders

func WithHeaders(headers map[string]string) ProviderClientOption

func WithMaxTokens

func WithMaxTokens(maxTokens int64) ProviderClientOption

func WithModel

func WithModel(model models.Model) ProviderClientOption

func WithOpenAIOptions

func WithOpenAIOptions(openaiOptions ...OpenAIOption) ProviderClientOption

func WithSystemMessage

func WithSystemMessage(systemMessage string) ProviderClientOption

type ProviderEvent

type ProviderEvent struct {
	Type EventType

	Content  string
	Thinking string
	Response *ProviderResponse
	ToolCall *message.ToolCall
	Error    error
}

type ProviderResponse

type ProviderResponse struct {
	Content      string
	ToolCalls    []message.ToolCall
	Usage        TokenUsage
	FinishReason message.FinishReason
}

type TokenUsage

type TokenUsage struct {
	InputTokens         int64
	OutputTokens        int64
	CacheCreationTokens int64
	CacheReadTokens     int64
}

type VertexAIClient

type VertexAIClient ProviderClient

Jump to

Keyboard shortcuts

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