Streams replies over SSE from any OpenAI-compatible server (oMLX, llama.cpp, Ollama, ...). Single binary that can install itself as an OS service; docker compose bundles llama.cpp + Gemma 4 E2B.
30 lines
678 B
Go
30 lines
678 B
Go
package views
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"github.com/a-h/templ"
|
|
"github.com/yuin/goldmark"
|
|
"github.com/yuin/goldmark/extension"
|
|
)
|
|
|
|
// md renders CommonMark + GFM. Raw HTML in model output is escaped
|
|
// (goldmark's default), so a reply can't inject markup into the page.
|
|
var md = goldmark.New(goldmark.WithExtensions(extension.GFM))
|
|
|
|
// Markdown renders model output as HTML, falling back to plain text.
|
|
func Markdown(src string) templ.Component {
|
|
var buf bytes.Buffer
|
|
if err := md.Convert([]byte(src), &buf); err != nil {
|
|
return Token(src)
|
|
}
|
|
return templ.Raw(buf.String())
|
|
}
|
|
|
|
func healthTrigger(h HealthInfo) string {
|
|
if h.Checking {
|
|
return "load"
|
|
}
|
|
return "every 30s"
|
|
}
|