handler

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChatCompletions

func ChatCompletions(client *wrapper.Client, registry *ToolSessionRegistry, logger *slog.Logger) http.HandlerFunc

ChatCompletions returns the handler for POST /v1/chat/completions. The registry holds parked tool sessions for faithful OpenAI tool round-trips; it may be nil when tool-calling is not needed (e.g. in tests exercising the method guard).

func Health

func Health() http.HandlerFunc

Health returns a simple health check handler.

func Models

func Models(client *wrapper.Client, logger *slog.Logger) http.HandlerFunc

Models returns the handler for GET /v1/models.

Types

type ToolSessionRegistry added in v0.4.0

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

ToolSessionRegistry holds parked tool sessions keyed by an opaque token that is embedded in the emitted tool_call IDs. It enforces a TTL and a maximum number of concurrently parked sessions, evicting (and tearing down) the oldest session when the cap is exceeded. It is safe for concurrent use.

func NewToolSessionRegistry added in v0.4.0

func NewToolSessionRegistry(ttl time.Duration, maxParked int, logger *slog.Logger) *ToolSessionRegistry

NewToolSessionRegistry constructs a registry with the given TTL and parked-cap.

func (*ToolSessionRegistry) StartGC added in v0.4.0

func (r *ToolSessionRegistry) StartGC(ctx context.Context)

StartGC launches a background sweep that evicts and tears down parked sessions older than the TTL. It stops when ctx is cancelled.

Jump to

Keyboard shortcuts

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