Documentation
¶
Index ¶
- Variables
- func SetupOllamaLocalInstance(ctx context.Context, tag string) (string, testcontainers.Container, func(), error)
- func SetupVLLMLocalInstance(ctx context.Context, model string, tag string) (string, testcontainers.Container, func(), error)
- type CapabilityConfig
- type ChatOption
- type GeminiProvider
- func (p *GeminiProvider) CanChat() bool
- func (p *GeminiProvider) CanEmbed() bool
- func (p *GeminiProvider) CanPrompt() bool
- func (p *GeminiProvider) CanStream() bool
- func (p *GeminiProvider) CanThink() bool
- func (p *GeminiProvider) GetBackendIDs() []string
- func (p *GeminiProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
- func (p *GeminiProvider) GetContextLength() int
- func (p *GeminiProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
- func (p *GeminiProvider) GetID() string
- func (p *GeminiProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
- func (p *GeminiProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
- func (p *GeminiProvider) GetType() string
- func (p *GeminiProvider) ModelName() string
- type LLMChatClient
- type LLMEmbedClient
- type LLMPromptExecClient
- type LLMStreamClient
- type Message
- type MockChatClient
- type MockEmbedClient
- type MockPromptClient
- type MockProvider
- func (m *MockProvider) CanChat() bool
- func (m *MockProvider) CanEmbed() bool
- func (m *MockProvider) CanPrompt() bool
- func (m *MockProvider) CanStream() bool
- func (m *MockProvider) CanThink() bool
- func (m *MockProvider) GetBackendIDs() []string
- func (m *MockProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
- func (m *MockProvider) GetContextLength() int
- func (m *MockProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
- func (m *MockProvider) GetID() string
- func (m *MockProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
- func (m *MockProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
- func (m *MockProvider) GetType() string
- func (m *MockProvider) ModelName() string
- type MockStreamClient
- type OllamaChatClient
- type OllamaEmbedClient
- type OllamaPromptClient
- type OllamaProvider
- func (p *OllamaProvider) CanChat() bool
- func (p *OllamaProvider) CanEmbed() bool
- func (p *OllamaProvider) CanPrompt() bool
- func (p *OllamaProvider) CanStream() bool
- func (p *OllamaProvider) CanThink() bool
- func (p *OllamaProvider) GetBackendIDs() []string
- func (p *OllamaProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
- func (p *OllamaProvider) GetContextLength() int
- func (p *OllamaProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
- func (p *OllamaProvider) GetID() string
- func (p *OllamaProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
- func (p *OllamaProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
- func (p *OllamaProvider) GetType() string
- func (p *OllamaProvider) ModelName() string
- type OpenAIProvider
- func (p *OpenAIProvider) CanChat() bool
- func (p *OpenAIProvider) CanEmbed() bool
- func (p *OpenAIProvider) CanPrompt() bool
- func (p *OpenAIProvider) CanStream() bool
- func (p *OpenAIProvider) CanThink() bool
- func (p *OpenAIProvider) GetBackendIDs() []string
- func (p *OpenAIProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
- func (p *OpenAIProvider) GetContextLength() int
- func (p *OpenAIProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
- func (p *OpenAIProvider) GetID() string
- func (p *OpenAIProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
- func (p *OpenAIProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
- func (p *OpenAIProvider) GetType() string
- func (p *OpenAIProvider) ModelName() string
- type Provider
- type StreamParcel
- type VLLMChatClient
- type VLLMPromptClient
- type VLLMStreamClient
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("operation not supported")
ErrNotSupported is returned when an operation is not supported.
Functions ¶
func SetupOllamaLocalInstance ¶ added in v0.0.8
func SetupVLLMLocalInstance ¶ added in v0.0.12
func SetupVLLMLocalInstance(ctx context.Context, model string, tag string) (string, testcontainers.Container, func(), error)
SetupVLLMLocalInstance creates a vLLM container for testing.
Types ¶
type CapabilityConfig ¶ added in v0.0.4
type CapabilityConfig struct {
ContextLength int
CanChat bool
CanEmbed bool
CanStream bool
CanPrompt bool
CanThink bool
}
CapabilityConfig holds the required capability information
type ChatOption ¶
func WithMaxTokens ¶ added in v0.0.8
func WithMaxTokens(tokens int) ChatOption
func WithTemperature ¶ added in v0.0.8
func WithTemperature(temp float64) ChatOption
Functional option constructors
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
func NewGeminiProvider ¶
func NewGeminiProvider(apiKey string, modelName string, baseURLs []string, cap CapabilityConfig, httpClient *http.Client) *GeminiProvider
func (*GeminiProvider) CanChat ¶
func (p *GeminiProvider) CanChat() bool
func (*GeminiProvider) CanEmbed ¶
func (p *GeminiProvider) CanEmbed() bool
func (*GeminiProvider) CanPrompt ¶
func (p *GeminiProvider) CanPrompt() bool
CanPrompt returns true if the model supports prompting.
func (*GeminiProvider) CanStream ¶
func (p *GeminiProvider) CanStream() bool
func (*GeminiProvider) CanThink ¶ added in v0.0.8
func (p *GeminiProvider) CanThink() bool
func (*GeminiProvider) GetBackendIDs ¶
func (p *GeminiProvider) GetBackendIDs() []string
func (*GeminiProvider) GetChatConnection ¶
func (p *GeminiProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
GetChatConnection returns an LLMChatClient for the specified backend ID.
func (*GeminiProvider) GetContextLength ¶
func (p *GeminiProvider) GetContextLength() int
func (*GeminiProvider) GetEmbedConnection ¶
func (p *GeminiProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
GetEmbedConnection returns an LLMEmbedClient for the specified backend ID.
func (*GeminiProvider) GetID ¶
func (p *GeminiProvider) GetID() string
func (*GeminiProvider) GetPromptConnection ¶
func (p *GeminiProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
GetPromptConnection returns an LLMPromptExecClient for the specified backend ID.
func (*GeminiProvider) GetStreamConnection ¶
func (p *GeminiProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
GetStreamConnection returns an LLMStreamClient for the specified backend ID.
func (*GeminiProvider) GetType ¶
func (p *GeminiProvider) GetType() string
func (*GeminiProvider) ModelName ¶
func (p *GeminiProvider) ModelName() string
type LLMChatClient ¶
type LLMChatClient interface {
Chat(ctx context.Context, Messages []Message, opts ...ChatOption) (Message, error)
}
Client interfaces for different capabilities
type LLMEmbedClient ¶
type LLMPromptExecClient ¶
type LLMStreamClient ¶
type LLMStreamClient interface {
Stream(ctx context.Context, prompt string) (<-chan *StreamParcel, error)
}
type MockChatClient ¶
type MockChatClient struct{}
MockChatClient is a mock implementation of LLMChatClient for testing.
func (*MockChatClient) Chat ¶
func (m *MockChatClient) Chat(ctx context.Context, messages []Message, opts ...ChatOption) (Message, error)
Chat returns a mock response.
func (*MockChatClient) Close ¶ added in v0.0.10
func (m *MockChatClient) Close() error
Close is a no-op for the mock client.
type MockEmbedClient ¶
type MockEmbedClient struct{}
MockEmbedClient is a mock implementation of LLMEmbedClient for testing.
func (*MockEmbedClient) Close ¶ added in v0.0.10
func (m *MockEmbedClient) Close() error
Close is a no-op for the mock client.
type MockPromptClient ¶
type MockPromptClient struct{}
MockPromptClient is a mock implementation of LLMPromptExecClient for testing.
func (*MockPromptClient) Close ¶ added in v0.0.10
func (m *MockPromptClient) Close() error
Close is a no-op for the mock client.
type MockProvider ¶
type MockProvider struct {
ID string
Name string
ContextLength int
CanChatFlag bool
CanEmbedFlag bool
CanStreamFlag bool
CanPromptFlag bool
Backends []string
}
MockProvider is a mock implementation of the Provider interface for testing.
func (*MockProvider) CanChat ¶
func (m *MockProvider) CanChat() bool
CanChat returns whether the mock provider can chat.
func (*MockProvider) CanEmbed ¶
func (m *MockProvider) CanEmbed() bool
CanEmbed returns whether the mock provider can embed.
func (*MockProvider) CanPrompt ¶
func (m *MockProvider) CanPrompt() bool
CanPrompt returns whether the mock provider can prompt.
func (*MockProvider) CanStream ¶
func (m *MockProvider) CanStream() bool
CanStream returns whether the mock provider can stream.
func (*MockProvider) CanThink ¶ added in v0.0.9
func (m *MockProvider) CanThink() bool
CanThink returns whether the mock provider can think.
func (*MockProvider) GetBackendIDs ¶
func (m *MockProvider) GetBackendIDs() []string
GetBackendIDs returns the backend IDs for the mock provider.
func (*MockProvider) GetChatConnection ¶
func (m *MockProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
GetChatConnection returns a mock chat client.
func (*MockProvider) GetContextLength ¶
func (m *MockProvider) GetContextLength() int
GetContextLength returns the context length for the mock provider.
func (*MockProvider) GetEmbedConnection ¶
func (m *MockProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
GetEmbedConnection returns a mock embed client.
func (*MockProvider) GetID ¶
func (m *MockProvider) GetID() string
GetID returns the ID for the mock provider.
func (*MockProvider) GetPromptConnection ¶
func (m *MockProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
GetPromptConnection returns a mock prompt client.
func (*MockProvider) GetStreamConnection ¶
func (m *MockProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
GetStreamConnection returns a mock stream client.
func (*MockProvider) GetType ¶
func (m *MockProvider) GetType() string
GetType returns the provider type for the mock provider.
func (*MockProvider) ModelName ¶
func (m *MockProvider) ModelName() string
ModelName returns the model name for the mock provider.
type MockStreamClient ¶ added in v0.0.10
type MockStreamClient struct{}
MockStreamClient is a mock implementation of LLMStreamClient for testing.
func (*MockStreamClient) Close ¶ added in v0.0.10
func (m *MockStreamClient) Close() error
Close is a no-op for the mock client.
func (*MockStreamClient) Stream ¶ added in v0.0.10
func (m *MockStreamClient) Stream(ctx context.Context, prompt string) (<-chan *StreamParcel, error)
Stream returns a channel with mock stream parcels.
type OllamaChatClient ¶
type OllamaChatClient struct {
// contains filtered or unexported fields
}
func (*OllamaChatClient) Chat ¶
func (c *OllamaChatClient) Chat(ctx context.Context, messages []Message, options ...ChatOption) (Message, error)
type OllamaEmbedClient ¶
type OllamaEmbedClient struct {
// contains filtered or unexported fields
}
type OllamaPromptClient ¶
type OllamaPromptClient struct {
// contains filtered or unexported fields
}
type OllamaProvider ¶
type OllamaProvider struct {
Name string
ID string
ContextLength int
SupportsChat bool
SupportsEmbed bool
SupportsStream bool
SupportsPrompt bool
SupportsThink bool
Backends []string
// contains filtered or unexported fields
}
func (*OllamaProvider) CanChat ¶
func (p *OllamaProvider) CanChat() bool
func (*OllamaProvider) CanEmbed ¶
func (p *OllamaProvider) CanEmbed() bool
func (*OllamaProvider) CanPrompt ¶
func (p *OllamaProvider) CanPrompt() bool
func (*OllamaProvider) CanStream ¶
func (p *OllamaProvider) CanStream() bool
func (*OllamaProvider) CanThink ¶ added in v0.0.8
func (p *OllamaProvider) CanThink() bool
func (*OllamaProvider) GetBackendIDs ¶
func (p *OllamaProvider) GetBackendIDs() []string
func (*OllamaProvider) GetChatConnection ¶
func (p *OllamaProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
func (*OllamaProvider) GetContextLength ¶
func (p *OllamaProvider) GetContextLength() int
func (*OllamaProvider) GetEmbedConnection ¶
func (p *OllamaProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
func (*OllamaProvider) GetID ¶
func (p *OllamaProvider) GetID() string
func (*OllamaProvider) GetPromptConnection ¶
func (p *OllamaProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
func (*OllamaProvider) GetStreamConnection ¶
func (p *OllamaProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
func (*OllamaProvider) GetType ¶
func (p *OllamaProvider) GetType() string
func (*OllamaProvider) ModelName ¶
func (p *OllamaProvider) ModelName() string
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey, modelName string, backendURLs []string, capability CapabilityConfig, httpClient *http.Client) *OpenAIProvider
func (*OpenAIProvider) CanChat ¶
func (p *OpenAIProvider) CanChat() bool
func (*OpenAIProvider) CanEmbed ¶
func (p *OpenAIProvider) CanEmbed() bool
func (*OpenAIProvider) CanPrompt ¶
func (p *OpenAIProvider) CanPrompt() bool
func (*OpenAIProvider) CanStream ¶
func (p *OpenAIProvider) CanStream() bool
func (*OpenAIProvider) CanThink ¶ added in v0.0.8
func (p *OpenAIProvider) CanThink() bool
func (*OpenAIProvider) GetBackendIDs ¶
func (p *OpenAIProvider) GetBackendIDs() []string
func (*OpenAIProvider) GetChatConnection ¶
func (p *OpenAIProvider) GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
func (*OpenAIProvider) GetContextLength ¶
func (p *OpenAIProvider) GetContextLength() int
func (*OpenAIProvider) GetEmbedConnection ¶
func (p *OpenAIProvider) GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
func (*OpenAIProvider) GetID ¶
func (p *OpenAIProvider) GetID() string
func (*OpenAIProvider) GetPromptConnection ¶
func (p *OpenAIProvider) GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
func (*OpenAIProvider) GetStreamConnection ¶
func (p *OpenAIProvider) GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
func (*OpenAIProvider) GetType ¶
func (p *OpenAIProvider) GetType() string
func (*OpenAIProvider) ModelName ¶
func (p *OpenAIProvider) ModelName() string
type Provider ¶
type Provider interface {
GetBackendIDs() []string // Available backend instances
ModelName() string // Model name (e.g., "llama2:latest")
GetID() string // unique identifier for the model provider
GetType() string // Type of the model provider
GetContextLength() int // Maximum context length supported
CanChat() bool // Supports chat interactions
CanEmbed() bool // Supports embeddings
CanStream() bool // Supports streaming
CanPrompt() bool // Supports prompting
CanThink() bool // Supports thinking
GetChatConnection(ctx context.Context, backendID string) (LLMChatClient, error)
GetPromptConnection(ctx context.Context, backendID string) (LLMPromptExecClient, error)
GetEmbedConnection(ctx context.Context, backendID string) (LLMEmbedClient, error)
GetStreamConnection(ctx context.Context, backendID string) (LLMStreamClient, error)
}
Provider is a provider of backend instances capable of executing requests with this Model.
func NewOllamaModelProvider ¶
func NewOllamaModelProvider(name string, backends []string, httpClient *http.Client, caps CapabilityConfig) Provider
NewOllamaModelProvider creates a provider with explicit capabilities
func NewVLLMModelProvider ¶
func NewVLLMModelProvider(modelName string, backends []string, client *http.Client, caps CapabilityConfig, authToken string) Provider
NewVLLMModelProvider creates a new vLLM model provider with explicit capabilities
type StreamParcel ¶
type VLLMChatClient ¶
type VLLMChatClient struct {
// contains filtered or unexported fields
}
VLLMChatClient handles chat interaction
func (*VLLMChatClient) Chat ¶
func (c *VLLMChatClient) Chat(ctx context.Context, messages []Message, options ...ChatOption) (Message, error)
Chat implements LLMChatClient interface
type VLLMPromptClient ¶
type VLLMPromptClient struct {
// contains filtered or unexported fields
}
VLLMPromptClient handles prompt execution
type VLLMStreamClient ¶ added in v0.0.11
type VLLMStreamClient struct {
// contains filtered or unexported fields
}
VLLMStreamClient handles streaming responses from vLLM
func (*VLLMStreamClient) Prompt ¶ added in v0.0.11
func (c *VLLMStreamClient) Prompt(ctx context.Context, systeminstruction string, temperature float32, prompt string) (string, error)
Prompt implements LLMPromptExecClient interface
func (*VLLMStreamClient) Stream ¶ added in v0.0.11
func (c *VLLMStreamClient) Stream(ctx context.Context, prompt string) (<-chan *StreamParcel, error)
Stream implements LLMStreamClient interface Stream implements LLMStreamClient interface