provider

package
v0.0.38 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: MIT Imports: 25 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 WithAnthropicShouldThinkFn

func WithAnthropicShouldThinkFn(fn func(string) bool) AnthropicOption

type AzureClient added in v0.0.35

type AzureClient ProviderClient

type BedrockClient

type BedrockClient ProviderClient

type BedrockOption

type BedrockOption func(*bedrockOptions)

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 added in v0.0.36

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
}

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 WithBedrockOptions

func WithBedrockOptions(bedrockOptions ...BedrockOption) ProviderClientOption

func WithGeminiOptions

func WithGeminiOptions(geminiOptions ...GeminiOption) 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
}

Jump to

Keyboard shortcuts

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