handler

package
v0.0.0-...-5ef2174 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeBadRequest   = "bad_request"
	CodeNotFound     = "not_found"
	CodeInvalidSkill = "invalid_skill"
	CodeTimeout      = "timeout"
	CodeInternal     = "internal"
)

Error code constants

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(c fiber.Ctx, err error) error

ErrorHandler is Fiber's global error handler. Maps Go errors to HTTP responses without leaking internal details.

func NewChatHandler

func NewChatHandler(chatter usecase.ChatProvider, cfg appconfig.RuntimeConfig, timeoutSeconds int) *chatHandler

NewChatHandler creates a new chat handler.

func NewConfigHandler

func NewConfigHandler(queries systemrepo.Querier, cfg appconfig.RuntimeConfig) *configHandler

NewConfigHandler creates a new config handler.

func NewEmbedHandler

func NewEmbedHandler(embedder usecase.EmbeddingProvider, embeddingService *usecase.EmbeddingService, riverClient *river.Client[pgx.Tx]) *embedHandler

NewEmbedHandler creates a new embed handler.

func NewJobHandler

func NewJobHandler(riverClient *river.Client[pgx.Tx]) *jobHandler

NewJobHandler creates a new job handler.

Types

type APIError

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

APIError is the standard error response format.

type ChatRequest

type ChatRequest struct {
	Skill    string            `json:"skill"`
	Model    string            `json:"model,omitempty"`
	Messages []usecase.Message `json:"messages"`
}

ChatRequest is the API request format for chat endpoints.

type ChatResponse

type ChatResponse struct {
	Model      string  `json:"model"`
	Content    string  `json:"content"`
	DurationMS float64 `json:"duration_ms"`
}

ChatResponse is the response format for blocking chat.

type ConfigResponse

type ConfigResponse struct {
	Models map[string]string `json:"models"`
	Prompt any               `json:"prompt"`
}

ConfigResponse is the response format for GET /api/v1/config.

type EmbedRequest

type EmbedRequest struct {
	Texts []string `json:"texts"`
}

EmbedRequest is the API request format for embedding.

type EmbedResponse

type EmbedResponse struct {
	Results []EmbedResult `json:"results"`
}

EmbedResponse is the response for synchronous embedding.

type EmbedResult

type EmbedResult struct {
	Text      string    `json:"text"`
	Embedding []float32 `json:"embedding"`
}

EmbedResult represents a single embedding.

type JobStatusResponse

type JobStatusResponse struct {
	ID          int64   `json:"id"`
	Kind        string  `json:"kind"`
	State       string  `json:"state"`
	QueuedAt    string  `json:"queued_at"`
	AttemptedAt *string `json:"attempted_at,omitempty"`
	CompletedAt *string `json:"completed_at,omitempty"`
	Error       *string `json:"error,omitempty"`
}

JobStatusResponse represents the status of a River job.

type QueuedResult

type QueuedResult struct {
	JobID  string `json:"job_id"`
	Status string `json:"status"`
	Count  int    `json:"count"`
}

QueuedResult is the response for async (queued) embedding.

type SetModelRequest

type SetModelRequest struct {
	Model string `json:"model"`
}

SetModelRequest is the request format for PUT /api/v1/config/models/:skill.

type SetModelResponse

type SetModelResponse struct {
	Skill     string `json:"skill"`
	Model     string `json:"model"`
	UpdatedAt string `json:"updated_at"`
}

SetModelResponse is the response format for setting a model.

type SetPromptRequest

type SetPromptRequest struct {
	OutputLength *string  `json:"output_length"`
	MaxTokens    *int     `json:"max_tokens"`
	Temperature  *float32 `json:"temperature"`
}

SetPromptRequest is the request format for PUT /api/v1/config/prompt.

Jump to

Keyboard shortcuts

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