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