Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
# Go 1.26.10 fixes GO-2026-6809 in crypto/x509.
# Go 1.26.11 fixes GO-2026-6809 in crypto/x509 and GO-2026-6859 in net/http.
# go.mod retains the downstream-consumer language floor.
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

- name: Verify modules
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

- name: Download suite
Expand All @@ -131,7 +131,7 @@ jobs:
# checked AGAINST, separate from the toolchain version.
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

- name: golangci-lint
Expand Down Expand Up @@ -287,15 +287,15 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
# Block on reachable vulnerabilities. Go 1.26.10 fixes the crypto/x509
# finding GO-2026-6809. Keep this toolchain
# Block on reachable vulnerabilities. Go 1.26.11 fixes the crypto/x509
# finding GO-2026-6809 and the net/http finding GO-2026-6859. Keep this toolchain
# aligned with the test jobs and Docker builder when patching Go.
# Do not bypass this gate with continue-on-error.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true
- name: Install govulncheck
# Pin govulncheck so a future major release (e.g. new finding
Expand Down Expand Up @@ -421,7 +421,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

# Build llm-init image first so the compose file's
Expand Down Expand Up @@ -683,7 +683,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

- name: Build static binary for release artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version: "1.26.10"
go-version: "1.26.11"
cache: true

- name: Initialize CodeQL
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ and the project adheres to [Semantic Versioning 2.0](https://semver.org/spec/v2.

## [Unreleased]

### Added

- `llm-init comfyui` runs the Model Console of a single-workflow ComfyUI
app. It reads a JSON app config (`COMFY_APP_CONFIG`) listing the models the
workflow needs, downloads them into `COMFY_MODELS_DIR` with resume and
sha256 verification (a marker under `.llm-init-verified/` skips re-hashing
on restart), re-fetches a model that disappears, probes ComfyUI's
`GET /system_stats`, and serves `GET /api/status` (ready only when every
model is verified and ComfyUI answers) plus a progress page at `/`. Models
of 64 MiB or more are fetched over `COMFY_DOWNLOAD_CONNECTIONS` (default 8)
byte ranges, checkpointed to `<file>.part.json`, since Hugging Face's CDN
throttles each connection. The LLM mode is untouched.
- `llm-init comfyui` honours `HF_ENDPOINT`: huggingface.co model URLs are
fetched from that mirror instead (same `/<repo>/resolve/<rev>/<path>`), so
an Olares with an internal mirror (`OLARES_SYSTEM_HUGGINGFACE_SERVICE`)
downloads from it and warms it for other machines.

### Changed

- A chat card whose `max_output_tokens` is unset, or as large as its
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

# Stage 1: build a static Linux binary with version metadata injected.
#
# Builder is pinned to golang:1.26.10-alpine to match the CI test/lint/vulncheck
# floor pinned in .github/workflows/ci.yml (`go-version: "1.26.10"`). The
# Builder is pinned to golang:1.26.11-alpine to match the CI test/lint/vulncheck
# floor pinned in .github/workflows/ci.yml (`go-version: "1.26.11"`). The
# downstream-consumer floor in go.mod (`go 1.23.0`) is intentionally
# separate — see CHANGELOG entry for v1.0.3.
#
# Pinned by digest for reproducible builds (the tag is kept inline so
# Dependabot's docker ecosystem can resolve + bump both in lockstep).
# Digest is the multi-arch image index (covers amd64 + arm64).
FROM --platform=$BUILDPLATFORM golang:1.26.10-alpine@sha256:27f2d3b83cfc5803c8078f8e730af0f7c431bf067afaec8f60a36fb763187cba AS builder
FROM --platform=$BUILDPLATFORM golang:1.26.11-alpine@sha256:ae52b5bc6ed045a9ed26ab03dc19327a802a9cc9aa8b27ed57f5c6b60579b0bb AS builder

ARG TARGETOS
ARG TARGETARCH
Expand Down
120 changes: 120 additions & 0 deletions cmd/llm-init/comfyui.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package main

import (
"context"
"errors"
"fmt"
"log/slog"
"net"
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"

"github.com/llm-init/llm-init/internal/comfyconsole"
"github.com/llm-init/llm-init/internal/config"
"github.com/llm-init/llm-init/internal/version"
)

// runComfyUI is `llm-init comfyui`: the Model Console of a single-workflow
// ComfyUI app (see internal/comfyconsole). It reads its own small env set
// and never loads the LLM config.
//
// COMFY_APP_CONFIG app config JSON (default /etc/comfy-app/app-config.json)
// COMFY_MODELS_DIR ComfyUI models root (required)
// COMFYUI_URL ComfyUI base URL (default http://127.0.0.1:8188)
// PORT listen port (default 8090)
// HF_TOKEN optional bearer token for huggingface.co downloads
// HF_ENDPOINT optional Hugging Face mirror; huggingface.co model URLs are fetched from it
// COMFY_DOWNLOAD_CONNECTIONS concurrent byte ranges per large model (default 8)
// COMFY_GROUPS model groups to install first: ids separated by commas, "all", or empty for the first
// COMFY_SELECTION_FILE where the installed groups are kept across restarts (on persistent storage)
// LOG_LEVEL / LOG_FORMAT as in the LLM mode
func runComfyUI(getenv config.Getenv, stderr *os.File) int {
env := func(k, def string) string {
if v := strings.TrimSpace(getenv(k)); v != "" {
return v
}
return def
}
logger := newLogger(env("LOG_LEVEL", "info"), env("LOG_FORMAT", config.LogFormatJSON), stderr)
slog.SetDefault(logger)

cfgFile := env("COMFY_APP_CONFIG", "/etc/comfy-app/app-config.json")
cfg, err := comfyconsole.LoadConfig(cfgFile)
if err != nil {
fmt.Fprintf(stderr, "config error: %v\n", err)
return exitConfig
}
mirrored, err := cfg.UseMirror(env("HF_ENDPOINT", ""))
if err != nil {
fmt.Fprintf(stderr, "config error: %v\n", err)
return exitConfig
}
modelsDir := env("COMFY_MODELS_DIR", "")
if modelsDir == "" {
fmt.Fprintln(stderr, "config error: COMFY_MODELS_DIR is required")
return exitConfig
}
var headers http.Header
if tok := env("HF_TOKEN", ""); tok != "" {
headers = http.Header{"Authorization": {"Bearer " + tok}}
}

conns := 0
if v := env("COMFY_DOWNLOAD_CONNECTIONS", ""); v != "" {
n, err := strconv.Atoi(v)
if err != nil || n < 1 {
fmt.Fprintf(stderr, "config error: COMFY_DOWNLOAD_CONNECTIONS must be a positive integer, got %q\n", v)
return exitConfig
}
conns = n
}

selFile := env("COMFY_SELECTION_FILE", "")
selected, err := comfyconsole.LoadSelection(cfg, selFile, env("COMFY_GROUPS", ""))
if err != nil {
fmt.Fprintf(stderr, "config error: %v\n", err)
return exitConfig
}

console := comfyconsole.New(comfyconsole.Options{
Config: cfg,
ModelsDir: modelsDir,
ComfyURL: strings.TrimRight(env("COMFYUI_URL", "http://127.0.0.1:8188"), "/"),
Headers: headers,
Connections: conns,
Selected: selected,
SelectionFile: selFile,
Logger: logger,
})

ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()

addr := net.JoinHostPort("", env("PORT", "8090"))
ln, err := net.Listen("tcp", addr)
if err != nil {
fmt.Fprintf(stderr, "listen %s: %v\n", addr, err)
return exitControlPlane
}
srv := &http.Server{Handler: console.Handler(), ReadHeaderTimeout: 10 * time.Second}
go func() {
if err := srv.Serve(ln); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Error("console server", "err", err)
stop()
}
}()
logger.Info("comfyui console started", "version", version.Version, "addr", addr,
"config", cfgFile, "models_dir", modelsDir, "models", len(cfg.Models), "groups", selected, "hf_mirrored", mirrored)

console.Run(ctx)

shutdownCtx, cancel := context.WithTimeout(context.Background(), shutdownGracePeriod)
defer cancel()
_ = srv.Shutdown(shutdownCtx)
return exitOK
}
3 changes: 3 additions & 0 deletions cmd/llm-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func run(args []string, stdout, stderr *os.File, getenv config.Getenv) int {
if getenv == nil {
getenv = os.Getenv
}
if len(args) > 0 && args[0] == "comfyui" {
return runComfyUI(getenv, stderr)
}

fs := flag.NewFlagSet("llm-init", flag.ContinueOnError)
fs.SetOutput(stderr)
Expand Down
Loading
Loading