Compare commits
2
Commits
02567c732f
...
495c89de0e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
495c89de0e
|
||
|
|
c158283f3d
|
@@ -33,6 +33,15 @@ import (
|
|||||||
openai "github.com/sashabaranov/go-openai"
|
openai "github.com/sashabaranov/go-openai"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Context keys for request-scoped values.
|
||||||
|
type key string
|
||||||
|
|
||||||
|
const (
|
||||||
|
logKey key = "log"
|
||||||
|
idKey key = "id"
|
||||||
|
ipKey key = "ip"
|
||||||
|
)
|
||||||
|
|
||||||
//go:embed all:static/*
|
//go:embed all:static/*
|
||||||
var static embed.FS
|
var static embed.FS
|
||||||
|
|
||||||
@@ -189,9 +198,9 @@ func (svc *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Enrich context with request-scoped values.
|
// Enrich context with request-scoped values.
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
ctx = context.WithValue(ctx, "log", log)
|
ctx = context.WithValue(ctx, logKey, log)
|
||||||
ctx = context.WithValue(ctx, "id", id)
|
ctx = context.WithValue(ctx, idKey, id)
|
||||||
ctx = context.WithValue(ctx, "ip", ip)
|
ctx = context.WithValue(ctx, ipKey, ip)
|
||||||
r = r.WithContext(ctx)
|
r = r.WithContext(ctx)
|
||||||
|
|
||||||
log.InfoContext(ctx, "handling")
|
log.InfoContext(ctx, "handling")
|
||||||
@@ -346,7 +355,7 @@ func (svc *Service) JobCount() int {
|
|||||||
func (svc *Service) home(w http.ResponseWriter, r *http.Request) {
|
func (svc *Service) home(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
ctx = r.Context()
|
ctx = r.Context()
|
||||||
log = ctx.Value("log").(*slog.Logger)
|
log = ctx.Value(logKey).(*slog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
if r.URL.Path != "/" {
|
if r.URL.Path != "/" {
|
||||||
@@ -408,7 +417,7 @@ type Response struct {
|
|||||||
func (svc *Service) voice(w http.ResponseWriter, r *http.Request) {
|
func (svc *Service) voice(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
ctx = r.Context()
|
ctx = r.Context()
|
||||||
log = ctx.Value("log").(*slog.Logger)
|
log = ctx.Value(logKey).(*slog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse request.
|
// Parse request.
|
||||||
@@ -619,7 +628,7 @@ type StreamMessage struct {
|
|||||||
func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) {
|
func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
ctx = r.Context()
|
ctx = r.Context()
|
||||||
log = ctx.Value("log").(*slog.Logger)
|
log = ctx.Value(logKey).(*slog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check that the response writer supports flushing.
|
// Check that the response writer supports flushing.
|
||||||
@@ -848,7 +857,7 @@ func (svc *Service) voiceStream(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (svc *Service) models(w http.ResponseWriter, r *http.Request) {
|
func (svc *Service) models(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
ctx = r.Context()
|
ctx = r.Context()
|
||||||
log = ctx.Value("log").(*slog.Logger)
|
log = ctx.Value(logKey).(*slog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
models, err := svc.llm.ListModels(ctx)
|
models, err := svc.llm.ListModels(ctx)
|
||||||
@@ -886,7 +895,7 @@ func (svc *Service) models(w http.ResponseWriter, r *http.Request) {
|
|||||||
func (svc *Service) voices(w http.ResponseWriter, r *http.Request) {
|
func (svc *Service) voices(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
ctx = r.Context()
|
ctx = r.Context()
|
||||||
log = ctx.Value("log").(*slog.Logger)
|
log = ctx.Value(logKey).(*slog.Logger)
|
||||||
)
|
)
|
||||||
|
|
||||||
voices, err := svc.tts.ListVoices(ctx)
|
voices, err := svc.tts.ListVoices(ctx)
|
||||||
|
|||||||
@@ -474,10 +474,18 @@ body {
|
|||||||
height: 1rem;
|
height: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-icon--up { display: inline; }
|
.scroll-icon--up {
|
||||||
.scroll-icon--down { display: none; }
|
display: inline;
|
||||||
#scroll.scrolled-up .scroll-icon--up { display: none; }
|
}
|
||||||
#scroll.scrolled-up .scroll-icon--down { display: inline; }
|
.scroll-icon--down {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#scroll.scrolled-up .scroll-icon--up {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#scroll.scrolled-up .scroll-icon--down {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
.footer__toolbar-btn--muted {
|
.footer__toolbar-btn--muted {
|
||||||
color: var(--color-red);
|
color: var(--color-red);
|
||||||
|
|||||||
@@ -218,7 +218,9 @@ class Odidere {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Wake lock: reacquire on visibility change
|
// Wake lock: reacquire on visibility change
|
||||||
this.document.addEventListener('visibilitychange', () => this.#handleVisibilityChange());
|
this.document.addEventListener('visibilitychange', () =>
|
||||||
|
this.#handleVisibilityChange(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user