mirror of
https://github.com/mudler/LocalAI.git
synced 2026-05-31 12:07:45 -04:00
The exported MaybeSetNodeHeaderForTest wrapper existed solely so the node_header_test.go file could live in package openai_test. That polluted the public API with a test-only shim. Move the test into package openai (internal test) and call maybeSetNodeHeader directly. Also drop the dead nodeIDContextKey constant and the c.Set(...) that wrote to it: nothing in the tree ever read it back. The streaming header fix uses a per-request chan instead of an Echo context value, since a context value would not survive across the request goroutine and worker goroutine boundary cleanly without extra synchronization. Refresh the maybeSetNodeHeader comment to spell out that streaming callers must NOT invoke it from the request goroutine before the worker is launched - that ordering is exactly the bug the streaming fix addresses. Add a helper resolveNodeID that returns the node ID string (without touching the response writer) so the streaming workers can share the "opt-in + loaded + has node ID" gating with the buffered handlers without duplicating the check. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-4-7[1m] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>