MCPcopy Create free account
hub / github.com/codehamr/codehamr / New

Function New

internal/llm/llm.go:238–246  ·  view source on GitHub ↗

New builds a Client governed by the caller's context, not http.Client.Timeout. That timeout is end-to-end (it covers body reads) and would kill a slow but legitimate SSE stream mid-flight on slow local backends. tui.Model's turnCtx is the single cancellation source; connect-level safety (DNS/TCP) is

(base, model, token string)

Source from the content-addressed store, hash-verified

236// enough that a proxy hiccup heals invisibly, and a *permanently* failing
237// request (e.g. a genuinely wrong model name 404ing forever) still surfaces
238// after ~22s total instead of minutes.
239var defaultRetryBackoff = []time.Duration{2 * time.Second, 5 * time.Second, 15 * time.Second}
240
241type Client struct {
242 BaseURL string
243 Model string
244 Token string // optional; empty = no Authorization header
245 HTTP *http.Client
246 // IdleTimeout caps the wait for the next SSE frame (see streamIdleTimeout).
247 // A field, not a bare const, only so tests can shorten it; New sets the
248 // default and nothing else writes it.
249 IdleTimeout time.Duration

Calls 1

idleTimeoutFromEnvFunction · 0.85