Documentation
¶
Overview ¶
Package server implements the HTTP server and routing logic for the Hapax LLM service. It provides endpoints for LLM completions, health checks, and Prometheus metrics.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompletionHandler ¶
type CompletionHandler struct {
// contains filtered or unexported fields
}
CompletionHandler processes LLM completion requests. It maintains a reference to the LLM client to generate responses.
func NewCompletionHandler ¶
func NewCompletionHandler(llm gollm.LLM) *CompletionHandler
NewCompletionHandler creates a new completion handler with the specified LLM client.
func (*CompletionHandler) ServeHTTP ¶
func (h *CompletionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for completion requests. It: 1. Validates the request method and body 2. Extracts the prompt from the request 3. Sends the prompt to the LLM for completion 4. Returns the generated completion to the client
type CompletionRequest ¶
type CompletionRequest struct {
Prompt string `json:"prompt"`
}
CompletionRequest represents an incoming completion request from clients. The prompt field contains the text to send to the LLM for completion.
type CompletionResponse ¶
type CompletionResponse struct {
Completion string `json:"completion"`
}
CompletionResponse represents the response sent back to clients. The completion field contains the generated text from the LLM.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router handles HTTP routing and middleware configuration. It sets up all endpoints and applies common middleware to requests.
func NewRouter ¶
NewRouter creates a new router with all endpoints configured. It: 1. Sets up common middleware (request ID, timing, panic recovery, CORS) 2. Configures the completion endpoint for LLM requests 3. Adds health check endpoint for container orchestration 4. Adds metrics endpoint for Prometheus monitoring
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP server instance. It wraps the standard library's http.Server with our configuration.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package handlers provides HTTP handlers for the Hapax server.
|
Package handlers provides HTTP handlers for the Hapax server. |
|
Package middleware provides various middleware functions for HTTP handlers.
|
Package middleware provides various middleware functions for HTTP handlers. |
|
Package processing provides request processing and response formatting for LLM interactions.
|
Package processing provides request processing and response formatting for LLM interactions. |
|
Package routing provides dynamic HTTP routing with versioning and health checks.
|
Package routing provides dynamic HTTP routing with versioning and health checks. |