Add admin UI
Some checks failed
CI / Test (pull_request) Failing after 1m33s
CI / Lint (pull_request) Failing after 13s
CI / Build (pull_request) Has been skipped
CI / Security Scan (pull_request) Failing after 4m47s
CI / Build and Push Docker Image (pull_request) Has been skipped

This commit is contained in:
2026-03-05 23:08:34 +00:00
parent 667217e66b
commit 7025ec746c
31 changed files with 5905 additions and 3 deletions

59
internal/admin/server.go Normal file
View File

@@ -0,0 +1,59 @@
package admin
import (
"log/slog"
"runtime"
"time"
"github.com/ajac-zero/latticelm/internal/config"
"github.com/ajac-zero/latticelm/internal/conversation"
"github.com/ajac-zero/latticelm/internal/providers"
)
// ProviderRegistry is an interface for provider registries.
type ProviderRegistry interface {
Get(name string) (providers.Provider, bool)
Models() []struct{ Provider, Model string }
ResolveModelID(model string) string
Default(model string) (providers.Provider, error)
}
// BuildInfo contains build-time information.
type BuildInfo struct {
Version string
BuildTime string
GitCommit string
GoVersion string
}
// AdminServer hosts the admin API and UI.
type AdminServer struct {
registry ProviderRegistry
convStore conversation.Store
cfg *config.Config
logger *slog.Logger
startTime time.Time
buildInfo BuildInfo
}
// New creates an AdminServer instance.
func New(registry ProviderRegistry, convStore conversation.Store, cfg *config.Config, logger *slog.Logger, buildInfo BuildInfo) *AdminServer {
return &AdminServer{
registry: registry,
convStore: convStore,
cfg: cfg,
logger: logger,
startTime: time.Now(),
buildInfo: buildInfo,
}
}
// GetBuildInfo returns a default BuildInfo if none provided.
func DefaultBuildInfo() BuildInfo {
return BuildInfo{
Version: "dev",
BuildTime: time.Now().Format(time.RFC3339),
GitCommit: "unknown",
GoVersion: runtime.Version(),
}
}