Documentation
¶
Overview ¶
Package grpcapi implements the proto services on top of proxydb, the registry, and the router.
Index ¶
- Constants
- func UsageProject(meta map[string]string) string
- type AdminServer
- func (s *AdminServer) CreateOrganization(ctx context.Context, req *pb.CreateOrganizationRequest) (*pb.CreateOrganizationResponse, error)
- func (s *AdminServer) CreateTeam(ctx context.Context, req *pb.CreateTeamRequest) (*pb.CreateTeamResponse, error)
- func (s *AdminServer) DeleteModel(ctx context.Context, req *pb.DeleteModelRequest) (*pb.DeleteModelResponse, error)
- func (s *AdminServer) DeleteOrganization(ctx context.Context, req *pb.DeleteOrganizationRequest) (*pb.DeleteOrganizationResponse, error)
- func (s *AdminServer) DeleteSpendLimit(ctx context.Context, req *pb.DeleteSpendLimitRequest) (*pb.DeleteSpendLimitResponse, error)
- func (s *AdminServer) DeleteTeam(ctx context.Context, req *pb.DeleteTeamRequest) (*pb.DeleteTeamResponse, error)
- func (s *AdminServer) DeleteUserRateLimit(ctx context.Context, req *pb.DeleteUserRateLimitRequest) (*pb.DeleteUserRateLimitResponse, error)
- func (s *AdminServer) DeleteVendorKey(ctx context.Context, req *pb.DeleteVendorKeyRequest) (*pb.DeleteVendorKeyResponse, error)
- func (s *AdminServer) DrainNode(ctx context.Context, req *pb.DrainNodeRequest) (*pb.DrainNodeResponse, error)
- func (s *AdminServer) GetConfig(ctx context.Context, _ *pb.GetConfigRequest) (*pb.GetConfigResponse, error)
- func (s *AdminServer) GetSpend(ctx context.Context, req *pb.GetSpendRequest) (*pb.GetSpendResponse, error)
- func (s *AdminServer) GetTeam(ctx context.Context, req *pb.GetTeamRequest) (*pb.GetTeamResponse, error)
- func (s *AdminServer) GetTeamSpend(ctx context.Context, req *pb.GetTeamSpendRequest) (*pb.GetTeamSpendResponse, error)
- func (s *AdminServer) ListAPIKeys(ctx context.Context, _ *pb.ListAPIKeysRequest) (*pb.ListAPIKeysResponse, error)
- func (s *AdminServer) ListNodeKeys(ctx context.Context, _ *pb.ListNodeKeysRequest) (*pb.ListNodeKeysResponse, error)
- func (s *AdminServer) ListNodes(ctx context.Context, _ *pb.ListNodesRequest) (*pb.ListNodesResponse, error)
- func (s *AdminServer) ListOrganizations(ctx context.Context, _ *pb.ListOrganizationsRequest) (*pb.ListOrganizationsResponse, error)
- func (s *AdminServer) ListSpendLimits(ctx context.Context, req *pb.ListSpendLimitsRequest) (*pb.ListSpendLimitsResponse, error)
- func (s *AdminServer) ListTeams(ctx context.Context, req *pb.ListTeamsRequest) (*pb.ListTeamsResponse, error)
- func (s *AdminServer) ListUserRateLimits(ctx context.Context, req *pb.ListUserRateLimitsRequest) (*pb.ListUserRateLimitsResponse, error)
- func (s *AdminServer) MintAPIKey(ctx context.Context, req *pb.MintAPIKeyRequest) (*pb.MintAPIKeyResponse, error)
- func (s *AdminServer) MintNodeKey(ctx context.Context, req *pb.MintNodeKeyRequest) (*pb.MintNodeKeyResponse, error)
- func (s *AdminServer) ReplaceRules(ctx context.Context, req *pb.ReplaceRulesRequest) (*pb.ReplaceRulesResponse, error)
- func (s *AdminServer) RevokeAPIKey(ctx context.Context, req *pb.RevokeAPIKeyRequest) (*pb.RevokeAPIKeyResponse, error)
- func (s *AdminServer) RevokeNodeKey(ctx context.Context, req *pb.RevokeNodeKeyRequest) (*pb.RevokeNodeKeyResponse, error)
- func (s *AdminServer) RotateEncryption(ctx context.Context, _ *pb.RotateEncryptionRequest) (*pb.RotateEncryptionResponse, error)
- func (s *AdminServer) SetAPIKeyPolicy(ctx context.Context, req *pb.SetAPIKeyPolicyRequest) (*pb.SetAPIKeyPolicyResponse, error)
- func (s *AdminServer) SetNodeManager(mgr *nodes.Manager)
- func (s *AdminServer) SetSpendLimit(ctx context.Context, req *pb.SetSpendLimitRequest) (*pb.SetSpendLimitResponse, error)
- func (s *AdminServer) SetSpendLimitResolver(fn func(subjectType, subjectID, period string) int64)
- func (s *AdminServer) SetSpendReader(fn SpendReader)
- func (s *AdminServer) SetUserRateLimit(ctx context.Context, req *pb.SetUserRateLimitRequest) (*pb.SetUserRateLimitResponse, error)
- func (s *AdminServer) SetVendorKey(ctx context.Context, req *pb.SetVendorKeyRequest) (*pb.SetVendorKeyResponse, error)
- func (s *AdminServer) UpdateTeam(ctx context.Context, req *pb.UpdateTeamRequest) (*pb.UpdateTeamResponse, error)
- func (s *AdminServer) UpsertModel(ctx context.Context, req *pb.UpsertModelRequest) (*pb.UpsertModelResponse, error)
- type BatchStore
- type KeyLimiter
- type NodeRegistryServer
- func (s *NodeRegistryServer) Heartbeat(ctx context.Context, req *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)
- func (s *NodeRegistryServer) RegisterNode(ctx context.Context, req *pb.RegisterNodeRequest) (*pb.RegisterNodeResponse, error)
- func (s *NodeRegistryServer) UnregisterNode(ctx context.Context, req *pb.UnregisterNodeRequest) (*pb.UnregisterNodeResponse, error)
- func (s *NodeRegistryServer) ValidateNode(ctx context.Context, req *pb.ValidateNodeRequest) (*pb.ValidateNodeResponse, error)
- type ProxyServer
- func (s *ProxyServer) Cache() TextCache
- func (s *ProxyServer) CancelBatch(ctx context.Context, req *pb.CancelBatchRequest) (*pb.CancelBatchResponse, error)
- func (s *ProxyServer) EvaluateRollouts(ctx context.Context, req *pb.EvaluateRolloutsRequest) (*pb.EvaluateRolloutsResponse, error)
- func (s *ProxyServer) GenerateImage(ctx context.Context, req *pb.GenerateImageRequest) (*pb.GenerateImageResponse, error)
- func (s *ProxyServer) GenerateText(ctx context.Context, req *pb.GenerateTextRequest) (*pb.GenerateTextResponse, error)
- func (s *ProxyServer) GenerateTextStream(req *pb.GenerateTextStreamRequest, ...) error
- func (s *ProxyServer) GetBatch(ctx context.Context, req *pb.GetBatchRequest) (*pb.Batch, error)
- func (s *ProxyServer) GetEmbeddings(ctx context.Context, req *pb.GetEmbeddingsRequest) (*pb.GetEmbeddingsResponse, error)
- func (s *ProxyServer) Guardrails() *guardrails.Guardrails
- func (s *ProxyServer) Judge(ctx context.Context, req *pb.JudgeRequest) (*pb.JudgeResponse, error)
- func (s *ProxyServer) JudgeStream(stream pb.GatewayService_JudgeStreamServer) error
- func (s *ProxyServer) ListBatchResults(ctx context.Context, req *pb.ListBatchResultsRequest) (*pb.ListBatchResultsResponse, error)
- func (s *ProxyServer) ListModels(ctx context.Context, _ *pb.ListModelsRequest) (*pb.ListModelsResponse, error)
- func (s *ProxyServer) SubmitBatch(ctx context.Context, req *pb.SubmitBatchRequest) (*pb.SubmitBatchResponse, error)
- func (s *ProxyServer) SynthesizeSpeech(ctx context.Context, req *pb.SynthesizeSpeechRequest) (*pb.SynthesizeSpeechResponse, error)
- func (s *ProxyServer) WithBatch(store BatchStore, maxItems int) *ProxyServer
- func (s *ProxyServer) WithCache(c TextCache) *ProxyServer
- func (s *ProxyServer) WithCircuitBreaker(cb router.CircuitBreaker) *ProxyServer
- func (s *ProxyServer) WithCooldown(store *cooldown.Store) *ProxyServer
- func (s *ProxyServer) WithGuardrails(g *guardrails.Guardrails) *ProxyServer
- func (s *ProxyServer) WithKeyLimiter(l KeyLimiter) *ProxyServer
- func (s *ProxyServer) WithSemanticCache(c SemanticCache) *ProxyServer
- func (s *ProxyServer) WithUpstreamTimeout(d time.Duration) *ProxyServer
- type SemanticCache
- type SnapshotProvider
- type SpendReader
- type TextCache
Constants ¶
const ( APIKeyAttribute = "api_key" UsageProjectAttribute = "usage_project" )
Reserved attribute names. Callers may set usage_project when one api key fronts many tenants; everything else in attributes is opaque to the proxy.
const ModalityAttribute = "modality"
ModalityAttribute is set by the proxy on speech and image calls so a rule can pin them without the caller naming a model. Reserved: a caller's own value is overwritten.
Variables ¶
This section is empty.
Functions ¶
func UsageProject ¶
UsageProject names the usage-collector project for one event. A caller that fronts many tenants sets usage_project itself; the api key alone would collapse them into one project.
Types ¶
type AdminServer ¶
type AdminServer struct {
pb.UnimplementedAdminServiceServer
// contains filtered or unexported fields
}
AdminServer implements AdminService.
func NewAdminServer ¶
func NewAdminServer(db *proxydb.DB, keyring *crypto.Keyring, onChange func()) *AdminServer
func (*AdminServer) CreateOrganization ¶ added in v0.14.0
func (s *AdminServer) CreateOrganization(ctx context.Context, req *pb.CreateOrganizationRequest) (*pb.CreateOrganizationResponse, error)
func (*AdminServer) CreateTeam ¶ added in v0.14.0
func (s *AdminServer) CreateTeam(ctx context.Context, req *pb.CreateTeamRequest) (*pb.CreateTeamResponse, error)
func (*AdminServer) DeleteModel ¶
func (s *AdminServer) DeleteModel(ctx context.Context, req *pb.DeleteModelRequest) (*pb.DeleteModelResponse, error)
func (*AdminServer) DeleteOrganization ¶ added in v0.14.0
func (s *AdminServer) DeleteOrganization(ctx context.Context, req *pb.DeleteOrganizationRequest) (*pb.DeleteOrganizationResponse, error)
func (*AdminServer) DeleteSpendLimit ¶
func (s *AdminServer) DeleteSpendLimit(ctx context.Context, req *pb.DeleteSpendLimitRequest) (*pb.DeleteSpendLimitResponse, error)
func (*AdminServer) DeleteTeam ¶ added in v0.14.0
func (s *AdminServer) DeleteTeam(ctx context.Context, req *pb.DeleteTeamRequest) (*pb.DeleteTeamResponse, error)
func (*AdminServer) DeleteUserRateLimit ¶
func (s *AdminServer) DeleteUserRateLimit(ctx context.Context, req *pb.DeleteUserRateLimitRequest) (*pb.DeleteUserRateLimitResponse, error)
func (*AdminServer) DeleteVendorKey ¶
func (s *AdminServer) DeleteVendorKey(ctx context.Context, req *pb.DeleteVendorKeyRequest) (*pb.DeleteVendorKeyResponse, error)
func (*AdminServer) DrainNode ¶
func (s *AdminServer) DrainNode(ctx context.Context, req *pb.DrainNodeRequest) (*pb.DrainNodeResponse, error)
func (*AdminServer) GetConfig ¶
func (s *AdminServer) GetConfig(ctx context.Context, _ *pb.GetConfigRequest) (*pb.GetConfigResponse, error)
func (*AdminServer) GetSpend ¶ added in v1.0.0
func (s *AdminServer) GetSpend(ctx context.Context, req *pb.GetSpendRequest) (*pb.GetSpendResponse, error)
func (*AdminServer) GetTeam ¶ added in v0.14.0
func (s *AdminServer) GetTeam(ctx context.Context, req *pb.GetTeamRequest) (*pb.GetTeamResponse, error)
func (*AdminServer) GetTeamSpend ¶ added in v0.14.0
func (s *AdminServer) GetTeamSpend(ctx context.Context, req *pb.GetTeamSpendRequest) (*pb.GetTeamSpendResponse, error)
func (*AdminServer) ListAPIKeys ¶
func (s *AdminServer) ListAPIKeys(ctx context.Context, _ *pb.ListAPIKeysRequest) (*pb.ListAPIKeysResponse, error)
func (*AdminServer) ListNodeKeys ¶
func (s *AdminServer) ListNodeKeys(ctx context.Context, _ *pb.ListNodeKeysRequest) (*pb.ListNodeKeysResponse, error)
func (*AdminServer) ListNodes ¶
func (s *AdminServer) ListNodes(ctx context.Context, _ *pb.ListNodesRequest) (*pb.ListNodesResponse, error)
func (*AdminServer) ListOrganizations ¶ added in v0.14.0
func (s *AdminServer) ListOrganizations(ctx context.Context, _ *pb.ListOrganizationsRequest) (*pb.ListOrganizationsResponse, error)
func (*AdminServer) ListSpendLimits ¶
func (s *AdminServer) ListSpendLimits(ctx context.Context, req *pb.ListSpendLimitsRequest) (*pb.ListSpendLimitsResponse, error)
func (*AdminServer) ListTeams ¶ added in v0.14.0
func (s *AdminServer) ListTeams(ctx context.Context, req *pb.ListTeamsRequest) (*pb.ListTeamsResponse, error)
func (*AdminServer) ListUserRateLimits ¶
func (s *AdminServer) ListUserRateLimits(ctx context.Context, req *pb.ListUserRateLimitsRequest) (*pb.ListUserRateLimitsResponse, error)
func (*AdminServer) MintAPIKey ¶
func (s *AdminServer) MintAPIKey(ctx context.Context, req *pb.MintAPIKeyRequest) (*pb.MintAPIKeyResponse, error)
func (*AdminServer) MintNodeKey ¶
func (s *AdminServer) MintNodeKey(ctx context.Context, req *pb.MintNodeKeyRequest) (*pb.MintNodeKeyResponse, error)
func (*AdminServer) ReplaceRules ¶
func (s *AdminServer) ReplaceRules(ctx context.Context, req *pb.ReplaceRulesRequest) (*pb.ReplaceRulesResponse, error)
func (*AdminServer) RevokeAPIKey ¶
func (s *AdminServer) RevokeAPIKey(ctx context.Context, req *pb.RevokeAPIKeyRequest) (*pb.RevokeAPIKeyResponse, error)
func (*AdminServer) RevokeNodeKey ¶
func (s *AdminServer) RevokeNodeKey(ctx context.Context, req *pb.RevokeNodeKeyRequest) (*pb.RevokeNodeKeyResponse, error)
func (*AdminServer) RotateEncryption ¶
func (s *AdminServer) RotateEncryption(ctx context.Context, _ *pb.RotateEncryptionRequest) (*pb.RotateEncryptionResponse, error)
func (*AdminServer) SetAPIKeyPolicy ¶ added in v1.0.0
func (s *AdminServer) SetAPIKeyPolicy(ctx context.Context, req *pb.SetAPIKeyPolicyRequest) (*pb.SetAPIKeyPolicyResponse, error)
func (*AdminServer) SetNodeManager ¶
func (s *AdminServer) SetNodeManager(mgr *nodes.Manager)
func (*AdminServer) SetSpendLimit ¶
func (s *AdminServer) SetSpendLimit(ctx context.Context, req *pb.SetSpendLimitRequest) (*pb.SetSpendLimitResponse, error)
func (*AdminServer) SetSpendLimitResolver ¶ added in v1.0.0
func (s *AdminServer) SetSpendLimitResolver(fn func(subjectType, subjectID, period string) int64)
SetSpendLimitResolver gives GetSpend the caps the throttle enforces, wildcard limits included.
func (*AdminServer) SetSpendReader ¶ added in v0.14.0
func (s *AdminServer) SetSpendReader(fn SpendReader)
SetSpendReader lets GetTeamSpend report what the gateway enforces; without it (no Redis) spend is unmetered and reported as such.
func (*AdminServer) SetUserRateLimit ¶
func (s *AdminServer) SetUserRateLimit(ctx context.Context, req *pb.SetUserRateLimitRequest) (*pb.SetUserRateLimitResponse, error)
func (*AdminServer) SetVendorKey ¶
func (s *AdminServer) SetVendorKey(ctx context.Context, req *pb.SetVendorKeyRequest) (*pb.SetVendorKeyResponse, error)
func (*AdminServer) UpdateTeam ¶ added in v0.14.0
func (s *AdminServer) UpdateTeam(ctx context.Context, req *pb.UpdateTeamRequest) (*pb.UpdateTeamResponse, error)
func (*AdminServer) UpsertModel ¶
func (s *AdminServer) UpsertModel(ctx context.Context, req *pb.UpsertModelRequest) (*pb.UpsertModelResponse, error)
type BatchStore ¶
type BatchStore interface {
CreateBatch(ctx context.Context, b *proxydb.Batch, items []*proxydb.BatchItem) (*proxydb.Batch, error)
GetBatch(ctx context.Context, id, apiKeyID string) (*proxydb.Batch, error)
GetBatchByClientBatchID(ctx context.Context, apiKeyID, clientBatchID string) (*proxydb.Batch, error)
ListBatchItems(ctx context.Context, batchID string, limit, offset int) ([]*proxydb.BatchItem, error)
}
BatchStore abstracts batch persistence operations.
type KeyLimiter ¶ added in v1.0.0
type KeyLimiter interface {
AdmitKey(ctx context.Context, keyName string, rpm int32, tpm, estimate int64) (settle func(actual int64), kind string, retry time.Duration)
}
KeyLimiter enforces a client key's own request and token rates over all models (throttle.Redis).
type NodeRegistryServer ¶
type NodeRegistryServer struct {
pb.UnimplementedNodeRegistryServiceServer
// contains filtered or unexported fields
}
NodeRegistryServer implements pb.NodeRegistryServiceServer.
func NewNodeRegistryServer ¶
func NewNodeRegistryServer(mgr *nodes.Manager, keyring *crypto.Keyring) *NodeRegistryServer
func (*NodeRegistryServer) Heartbeat ¶
func (s *NodeRegistryServer) Heartbeat(ctx context.Context, req *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)
func (*NodeRegistryServer) RegisterNode ¶
func (s *NodeRegistryServer) RegisterNode(ctx context.Context, req *pb.RegisterNodeRequest) (*pb.RegisterNodeResponse, error)
func (*NodeRegistryServer) UnregisterNode ¶
func (s *NodeRegistryServer) UnregisterNode(ctx context.Context, req *pb.UnregisterNodeRequest) (*pb.UnregisterNodeResponse, error)
func (*NodeRegistryServer) ValidateNode ¶
func (s *NodeRegistryServer) ValidateNode(ctx context.Context, req *pb.ValidateNodeRequest) (*pb.ValidateNodeResponse, error)
type ProxyServer ¶
type ProxyServer struct {
pb.UnimplementedGatewayServiceServer
// contains filtered or unexported fields
}
ProxyServer implements the data-plane GatewayService.
func NewProxyServer ¶
func NewProxyServer(snapshots SnapshotProvider, throttle router.Throttle) *ProxyServer
func (*ProxyServer) Cache ¶
func (s *ProxyServer) Cache() TextCache
Cache returns the configured response cache.
func (*ProxyServer) CancelBatch ¶
func (s *ProxyServer) CancelBatch(ctx context.Context, req *pb.CancelBatchRequest) (*pb.CancelBatchResponse, error)
func (*ProxyServer) EvaluateRollouts ¶
func (s *ProxyServer) EvaluateRollouts(ctx context.Context, req *pb.EvaluateRolloutsRequest) (*pb.EvaluateRolloutsResponse, error)
EvaluateRollouts scores multiple candidate trajectories against state and criteria in parallel for speculative decoding and Best-of-N selection.
func (*ProxyServer) GenerateImage ¶
func (s *ProxyServer) GenerateImage(ctx context.Context, req *pb.GenerateImageRequest) (*pb.GenerateImageResponse, error)
func (*ProxyServer) GenerateText ¶
func (s *ProxyServer) GenerateText(ctx context.Context, req *pb.GenerateTextRequest) (*pb.GenerateTextResponse, error)
func (*ProxyServer) GenerateTextStream ¶
func (s *ProxyServer) GenerateTextStream(req *pb.GenerateTextStreamRequest, stream pb.GatewayService_GenerateTextStreamServer) error
GenerateTextStream handles streaming text generation.
func (*ProxyServer) GetBatch ¶
func (s *ProxyServer) GetBatch(ctx context.Context, req *pb.GetBatchRequest) (*pb.Batch, error)
func (*ProxyServer) GetEmbeddings ¶
func (s *ProxyServer) GetEmbeddings(ctx context.Context, req *pb.GetEmbeddingsRequest) (*pb.GetEmbeddingsResponse, error)
GetEmbeddings computes vector embeddings for inputs. Invariant: Vector space isolation is strictly preserved. Cross-model fallbacks are disallowed.
func (*ProxyServer) Guardrails ¶
func (s *ProxyServer) Guardrails() *guardrails.Guardrails
Guardrails returns the configured guardrails.
func (*ProxyServer) Judge ¶
func (s *ProxyServer) Judge(ctx context.Context, req *pb.JudgeRequest) (*pb.JudgeResponse, error)
Judge answers typed questions about one state. It is a decision RPC: no text is generated, and the answers carry the probabilities the caller routes on.
func (*ProxyServer) JudgeStream ¶
func (s *ProxyServer) JudgeStream(stream pb.GatewayService_JudgeStreamServer) error
JudgeStream provides bidirectional streaming decisions for real-time agent evaluation and robotics control loops.
func (*ProxyServer) ListBatchResults ¶
func (s *ProxyServer) ListBatchResults(ctx context.Context, req *pb.ListBatchResultsRequest) (*pb.ListBatchResultsResponse, error)
func (*ProxyServer) ListModels ¶
func (s *ProxyServer) ListModels(ctx context.Context, _ *pb.ListModelsRequest) (*pb.ListModelsResponse, error)
ListModels returns only models the calling client may call: it holds their vendor key, and its team (if any) allows them.
func (*ProxyServer) SubmitBatch ¶
func (s *ProxyServer) SubmitBatch(ctx context.Context, req *pb.SubmitBatchRequest) (*pb.SubmitBatchResponse, error)
func (*ProxyServer) SynthesizeSpeech ¶
func (s *ProxyServer) SynthesizeSpeech(ctx context.Context, req *pb.SynthesizeSpeechRequest) (*pb.SynthesizeSpeechResponse, error)
func (*ProxyServer) WithBatch ¶
func (s *ProxyServer) WithBatch(store BatchStore, maxItems int) *ProxyServer
WithBatch configures the batch store and max item limit on the server.
func (*ProxyServer) WithCache ¶
func (s *ProxyServer) WithCache(c TextCache) *ProxyServer
WithCache configures response caching on the server.
func (*ProxyServer) WithCircuitBreaker ¶
func (s *ProxyServer) WithCircuitBreaker(cb router.CircuitBreaker) *ProxyServer
WithCircuitBreaker configures upstream circuit breaking on the server.
func (*ProxyServer) WithCooldown ¶ added in v0.13.1
func (s *ProxyServer) WithCooldown(store *cooldown.Store) *ProxyServer
WithCooldown honours vendor Retry-After by pausing models in store.
func (*ProxyServer) WithGuardrails ¶
func (s *ProxyServer) WithGuardrails(g *guardrails.Guardrails) *ProxyServer
WithGuardrails configures guardrails on the server.
func (*ProxyServer) WithKeyLimiter ¶ added in v1.0.0
func (s *ProxyServer) WithKeyLimiter(l KeyLimiter) *ProxyServer
WithKeyLimiter enforces each key's rpm_limit and tpm_limit.
func (*ProxyServer) WithSemanticCache ¶
func (s *ProxyServer) WithSemanticCache(c SemanticCache) *ProxyServer
WithSemanticCache configures latent-space caching, consulted after an exact miss.
func (*ProxyServer) WithUpstreamTimeout ¶
func (s *ProxyServer) WithUpstreamTimeout(d time.Duration) *ProxyServer
WithUpstreamTimeout bounds each attempt against an upstream vendor.
type SemanticCache ¶
type SemanticCache interface {
Get(ctx context.Context, apiKeyID string, configVersion int64, req *pb.GenerateTextRequest) (*pb.GenerateTextResponse, float32, bool, error)
Set(ctx context.Context, apiKeyID string, configVersion int64, req *pb.GenerateTextRequest, resp *pb.GenerateTextResponse) error
}
SemanticCache serves responses for prompts that are close in latent space.
type SnapshotProvider ¶
SnapshotProvider hands out the active config view (the registry Loader in production, a fixed snapshot in tests).
type SpendReader ¶ added in v0.14.0
type SpendReader func(ctx context.Context, subject, subjectID, period string) (int64, time.Time, error)
SpendReader reads a spend counter as the throttle keeps it.
type TextCache ¶
type TextCache interface {
Get(ctx context.Context, apiKeyID string, configVersion int64, req *pb.GenerateTextRequest) (*pb.GenerateTextResponse, bool, error)
Set(ctx context.Context, apiKeyID string, configVersion int64, req *pb.GenerateTextRequest, resp *pb.GenerateTextResponse) error
}
TextCache stores and retrieves cached LLM responses.