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

Method postChat

internal/llm/llm.go:379–393  ·  view source on GitHub ↗

postChat dispatches via doPost; on a 400 rejecting reasoning it drops reasoning_effort for this Client's lifetime and retries once. Two wild flavours, both caught by substring match: newer OpenAI models ("reasoning_effort … not supported") and Ollama non-thinking models (" does not support th

(parent context.Context, body chatRequest)

Source from the content-addressed store, hash-verified

377 Elapsed: time.Since(start),
378 })
379}
380
381// sendEvent puts e on out, bailing if parent cancels first, so a slow or
382// vanished consumer after Ctrl+C can't wedge the stream goroutine on a full
383// buffer.
384func sendEvent(parent context.Context, out chan<- Event, e Event) bool {
385 select {
386 case out <- e:
387 return true
388 case <-parent.Done():
389 return false
390 }
391}
392
393// sendChat POSTs the request and returns the response on 200. On failure it
394// returns the Event the caller forwards, populated with Kind/Err/Budget. The
395// body is closed on every non-200 branch; 200 leaves it open for the caller.
396func (c *Client) sendChat(parent context.Context, msgs []chmctx.Message, tools []Tool) (*http.Response, *Event) {

Callers 2

ProbeMethod · 0.95
sendChatMethod · 0.95

Calls 1

doPostMethod · 0.95

Tested by

no test coverage detected