Documentation
¶
Index ¶
- type APIKeyConfig
- type ConfigStore
- type LLMClient
- func (c *LLMClient) NewChatCompletion(ctx context.Context, in *chat_completion.Request) (*chat_completion.Response, error)
- func (c *LLMClient) NewEmbedding(ctx context.Context, in *embeddings.Request) (*embeddings.Response, error)
- func (c *LLMClient) NewResponses(ctx context.Context, in *responses.Request) (*responses.Response, error)
- func (c *LLMClient) NewSpeech(ctx context.Context, in *speech.Request) (*speech.Response, error)
- func (c *LLMClient) NewStreamingChatCompletion(ctx context.Context, in *chat_completion.Request) (chan *chat_completion.ResponseChunk, error)
- func (c *LLMClient) NewStreamingResponses(ctx context.Context, in *responses.Request) (chan *responses.ResponseChunk, error)
- func (c *LLMClient) NewStreamingSpeech(ctx context.Context, in *speech.Request) (chan *speech.ResponseChunk, error)
- type LLMGateway
- func (g *LLMGateway) HandleRequest(ctx context.Context, providerName llm.ProviderName, key string, r *llm.Request) (*llm.Response, error)
- func (g *LLMGateway) HandleStreamingRequest(ctx context.Context, providerName llm.ProviderName, key string, r *llm.Request) (*llm.StreamingResponse, error)
- func (g *LLMGateway) UseMiddleware(middleware ...Middleware)
- type LLMGatewayAdapter
- type Middleware
- type ProviderConfig
- type RateLimit
- type RequestHandler
- type StreamingRequestHandler
- type VirtualKeyConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyConfig ¶
type APIKeyConfig struct {
ProviderName llm.ProviderName
APIKey string
Name string
RateLimits []RateLimit
Weight int
Enabled bool
IsDefault bool
}
APIKeyConfig contains API key information for a provider. This is the gateway's own type, independent of services layer.
type ConfigStore ¶
type ConfigStore interface {
// GetProviderConfig returns provider configuration and associated API keys.
GetProviderConfig(providerName llm.ProviderName) (*ProviderConfig, error)
// GetVirtualKey returns virtual key configuration for access control.
GetVirtualKey(secretKey string) (*VirtualKeyConfig, error)
}
ConfigStore is the interface required by LLMGateway to get provider and virtual key configurations. Implementations: - InMemoryConfigStore: for SDK consumers with direct API keys - ServiceConfigStore (in gateway_adapter): for server-side use with database-backed configs - ExternalConfigStore (in gateway_adapter): for SDK consumers calling agent-server API
type LLMClient ¶
type LLMClient struct {
LLMGatewayAdapter
// contains filtered or unexported fields
}
LLMClient wraps an LLMGatewayAdapter and provides a high-level interface
func NewLLMClient ¶
func NewLLMClient(p LLMGatewayAdapter, providerName llm.ProviderName, model string) *LLMClient
NewLLMClient creates a new LLM client with the given provider.
func (*LLMClient) NewChatCompletion ¶
func (c *LLMClient) NewChatCompletion(ctx context.Context, in *chat_completion.Request) (*chat_completion.Response, error)
func (*LLMClient) NewEmbedding ¶
func (c *LLMClient) NewEmbedding(ctx context.Context, in *embeddings.Request) (*embeddings.Response, error)
func (*LLMClient) NewResponses ¶
func (*LLMClient) NewStreamingChatCompletion ¶
func (c *LLMClient) NewStreamingChatCompletion(ctx context.Context, in *chat_completion.Request) (chan *chat_completion.ResponseChunk, error)
func (*LLMClient) NewStreamingResponses ¶
func (c *LLMClient) NewStreamingResponses(ctx context.Context, in *responses.Request) (chan *responses.ResponseChunk, error)
NewStreamingResponses invokes the LLM and streams responses via callback
func (*LLMClient) NewStreamingSpeech ¶ added in v0.1.11
type LLMGateway ¶
type LLMGateway struct {
ConfigStore ConfigStore
// contains filtered or unexported fields
}
func NewLLMGateway ¶
func NewLLMGateway(ConfigStore ConfigStore) *LLMGateway
func (*LLMGateway) HandleRequest ¶
func (*LLMGateway) HandleStreamingRequest ¶
func (g *LLMGateway) HandleStreamingRequest(ctx context.Context, providerName llm.ProviderName, key string, r *llm.Request) (*llm.StreamingResponse, error)
func (*LLMGateway) UseMiddleware ¶
func (g *LLMGateway) UseMiddleware(middleware ...Middleware)
type LLMGatewayAdapter ¶
type LLMGatewayAdapter interface {
// NewResponses makes a non-streaming LLM call
NewResponses(ctx context.Context, provider llm.ProviderName, req *responses.Request) (*responses.Response, error)
// NewStreamingResponses makes a streaming LLM call
NewStreamingResponses(ctx context.Context, provider llm.ProviderName, req *responses.Request) (chan *responses.ResponseChunk, error)
// NewEmbedding
NewEmbedding(ctx context.Context, providerName llm.ProviderName, req *embeddings.Request) (*embeddings.Response, error)
// NewChatCompletion
NewChatCompletion(ctx context.Context, providerName llm.ProviderName, req *chat_completion.Request) (*chat_completion.Response, error)
// NewStreamingChatCompletion
NewStreamingChatCompletion(ctx context.Context, providerName llm.ProviderName, req *chat_completion.Request) (chan *chat_completion.ResponseChunk, error)
// NewSpeech
NewSpeech(ctx context.Context, providerName llm.ProviderName, req *speech.Request) (*speech.Response, error)
// NewStreamingSpeech
NewStreamingSpeech(ctx context.Context, providerName llm.ProviderName, req *speech.Request) (chan *speech.ResponseChunk, error)
}
LLMGatewayAdapter is the interface for making LLM calls. Similar to ConversationPersistenceAdapter, it can be implemented by: - InternalLLMProvider: uses the internal gateway (for server-side) - ExternalLLMProvider: calls agent-server via HTTP (for SDK consumers)
type Middleware ¶
type Middleware interface {
HandleRequest(next RequestHandler) RequestHandler
HandleStreamingRequest(next StreamingRequestHandler) StreamingRequestHandler
}
type ProviderConfig ¶
type ProviderConfig struct {
ProviderName llm.ProviderName
BaseURL string
CustomHeaders map[string]string
ApiKeys []*APIKeyConfig
}
ProviderConfig contains provider-level configuration. This is the gateway's own type, independent of services layer.
type RequestHandler ¶
type StreamingRequestHandler ¶
type StreamingRequestHandler func(ctx context.Context, providerName llm.ProviderName, key string, r *llm.Request) (*llm.StreamingResponse, error)
type VirtualKeyConfig ¶
type VirtualKeyConfig struct {
SecretKey string
AllowedProviders []llm.ProviderName
AllowedModels []string
RateLimits []RateLimit
}
VirtualKeyConfig contains virtual key access configuration. This is the gateway's own type, independent of services layer.