server

package
v0.9.76 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 84 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKeepAlive   = 5 * time.Minute
	DesktopAPIProtocol = "2"
)

Variables

This section is empty.

Functions

func LogMiddleware

func LogMiddleware(next http.Handler) http.Handler

LogMiddleware logs HTTP requests to the standard logger with timing info.

func SetupLogging

func SetupLogging(buf *LogBuffer)

SetupLogging redirects log output to the in-memory buffer and, by default, mirrors it to stderr and ~/.csghub-lite/logs/csghub-lite.log.

Types

type LogBuffer

type LogBuffer struct {
	// contains filtered or unexported fields
}

LogBuffer is a thread-safe ring buffer for log lines, supporting SSE subscribers.

func NewLogBuffer

func NewLogBuffer(maxSize int) *LogBuffer

func (*LogBuffer) Recent

func (lb *LogBuffer) Recent(n int) []string

func (*LogBuffer) Subscribe

func (lb *LogBuffer) Subscribe() chan string

func (*LogBuffer) Unsubscribe

func (lb *LogBuffer) Unsubscribe(ch chan string)

func (*LogBuffer) Write

func (lb *LogBuffer) Write(p []byte) (n int, err error)

type ProviderPoolEvaluationLimits added in v0.9.57

type ProviderPoolEvaluationLimits struct {
	MaxQueries            int
	MaxRepeats            int
	MaxOutputTokens       int
	MaxRequestTimeoutSecs int
}

type ProviderPoolEvaluationPreview added in v0.9.57

type ProviderPoolEvaluationPreview struct {
	EvaluationMode                string
	EligibleSnapshotCount         int
	SelectedSnapshotCount         int
	DirectCandidateCalls          int
	JudgeCalls                    int
	MaxJudgeCalls                 int
	MaxTotalCalls                 int
	JudgePromptTokens             int64
	MaxJudgeTokenExposure         int64
	MaxTokenExposure              int64
	KnownJudgeEstimatedCost       float64
	KnownEstimatedCost            float64
	Currency                      string
	UnknownPriceMembers           []routerprofile.Target
	JudgePriceKnown               bool
	RequiresUnknownPricingConsent bool
	Limits                        ProviderPoolEvaluationLimits
}

type ProviderPoolEvaluationRequest added in v0.9.57

type ProviderPoolEvaluationRequest struct {
	PoolID                string
	EvaluationMode        string
	BaseProfileID         string
	JudgeModel            string
	MaxQueries            int
	Repeats               int
	MaxOutputTokens       int
	RequestTimeoutSeconds int
	BudgetCurrency        string
	BudgetAmount          float64
	AllowUnknownPricing   bool
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config, version string) *Server

func (*Server) ActivateRouterProfile added in v0.9.57

func (s *Server) ActivateRouterProfile(ctx context.Context, poolID, profileID, actor, reason string) (routerprofile.Activation, error)

ActivateRouterProfile validates, activates, and publishes a profile while holding the runtime profile lock, so requests see either cache generation.

func (*Server) CancelProviderPoolEvaluationJob added in v0.9.57

func (s *Server) CancelProviderPoolEvaluationJob(ctx context.Context, poolID, jobID string) error

func (*Server) CreateProviderPoolEvaluationJob added in v0.9.57

func (s *Server) CreateProviderPoolEvaluationJob(ctx context.Context, request ProviderPoolEvaluationRequest) (routerprofile.EvaluationJob, error)

func (*Server) GetProviderPoolEvaluationJob added in v0.9.57

func (s *Server) GetProviderPoolEvaluationJob(ctx context.Context, poolID, jobID string) (routerprofile.EvaluationJob, []routerprofile.EvaluationCell, error)

func (*Server) ListProviderPoolEvaluationJobs added in v0.9.57

func (s *Server) ListProviderPoolEvaluationJobs(ctx context.Context, poolID string, status routerprofile.JobStatus, options routerprofile.ListOptions) ([]routerprofile.EvaluationJob, error)

func (*Server) PreviewProviderPoolEvaluation added in v0.9.57

func (s *Server) PreviewProviderPoolEvaluation(ctx context.Context, request ProviderPoolEvaluationRequest) (ProviderPoolEvaluationPreview, error)

PreviewProviderPoolEvaluation resolves pricing from the model catalog at request time. It performs no inference and does not create a job.

func (*Server) RollbackRouterProfile added in v0.9.57

func (s *Server) RollbackRouterProfile(ctx context.Context, poolID, expectedCurrent, actor, reason string) (routerprofile.Activation, error)

RollbackRouterProfile rolls back in storage, validates the resulting active profile against current members, and atomically refreshes the runtime cache.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

func (*Server) ValidateRouterProfile added in v0.9.57

func (s *Server) ValidateRouterProfile(ctx context.Context, poolID, profileID string) (routerprofile.Profile, error)

ValidateRouterProfile validates a stored profile against the current pool and the activation held-out gates. It performs no mutation.

Source Files

Jump to

Keyboard shortcuts

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