grpcapi

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package grpcapi implements the proto services on top of proxydb, the registry, and the router.

Index

Constants

View Source
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.

View Source
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

func UsageProject(meta map[string]string) string

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 LLMProxyAdminService.

func NewAdminServer

func NewAdminServer(db *proxydb.DB, keyring *crypto.Keyring, onChange func()) *AdminServer

func (*AdminServer) DeleteModel

func (*AdminServer) DeleteSpendLimit

func (*AdminServer) DeleteUserRateLimit

func (*AdminServer) DeleteVendorKey

func (*AdminServer) DrainNode

func (*AdminServer) GetConfig

func (*AdminServer) ListAPIKeys

func (*AdminServer) ListNodeKeys

func (*AdminServer) ListNodes

func (*AdminServer) ListSpendLimits

func (*AdminServer) ListUserRateLimits

func (*AdminServer) MintAPIKey

func (*AdminServer) MintNodeKey

func (*AdminServer) ReplaceRules

func (*AdminServer) RevokeAPIKey

func (*AdminServer) RevokeNodeKey

func (*AdminServer) RotateEncryption

func (*AdminServer) SetNodeManager

func (s *AdminServer) SetNodeManager(mgr *nodes.Manager)

func (*AdminServer) SetSpendLimit

func (*AdminServer) SetUserRateLimit

func (*AdminServer) SetVendorKey

func (*AdminServer) UpsertModel

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 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 (*NodeRegistryServer) RegisterNode

func (*NodeRegistryServer) UnregisterNode

func (*NodeRegistryServer) ValidateNode

type ProxyServer

type ProxyServer struct {
	pb.UnimplementedGatewayServiceServer
	// contains filtered or unexported fields
}

ProxyServer implements the data-plane LLMProxyService.

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 (*ProxyServer) EvaluateRollouts

EvaluateRollouts scores multiple candidate trajectories against state and criteria in parallel for speculative decoding and Best-of-N selection.

func (*ProxyServer) GenerateImage

func (*ProxyServer) GenerateText

func (*ProxyServer) GenerateTextStream

GenerateTextStream handles streaming text generation.

func (*ProxyServer) GetBatch

func (s *ProxyServer) GetBatch(ctx context.Context, req *pb.GetBatchRequest) (*pb.Batch, error)

func (*ProxyServer) GetEmbeddings

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 (*ProxyServer) ListModels

ListModels returns only models the calling client holds a vendor key for.

func (*ProxyServer) SubmitBatch

func (*ProxyServer) SynthesizeSpeech

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) WithGuardrails

func (s *ProxyServer) WithGuardrails(g *guardrails.Guardrails) *ProxyServer

WithGuardrails configures guardrails on the server.

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

type SnapshotProvider interface {
	Snapshot() *registry.Snapshot
}

SnapshotProvider hands out the active config view (the registry Loader in production, a fixed snapshot in tests).

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.

Jump to

Keyboard shortcuts

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