Skip to content

fix: echo the actually-used model in chat completion responses - #41

Open
hadooptofly wants to merge 1 commit into
yushangxiao:mainfrom
hadooptofly:fix/echo-request-model
Open

hadooptofly wants to merge 1 commit into
yushangxiao:mainfrom
hadooptofly:fix/echo-request-model

Conversation

@hadooptofly

Copy link
Copy Markdown

What changed

The OpenAI-compatible response's model field was hardcoded to claude-3-7-sonnet-20250219 regardless of which model was actually requested/used, so a request for e.g. claude-opus-5 would come back with "model":"claude-3-7-sonnet-20250219" even though the reply content itself was genuinely answered by the requested model.

  • Client now stores the originally requested model in requestModel, captured in NewClient before CreateConversation mutates c.model (e.g. stripping the -think suffix).
  • model.ReturnOpenAIResponse now takes a modelName parameter; both streamRespose and noStreamResponse use it for the response's "model" field instead of the hardcoded string. Falls back to the old default only if no model name is supplied.
  • go.mod: promoted gopkg.in/yaml.v3 to a direct dependency to match its direct import in config/config.go (was incorrectly marked // indirect).

Why

Response metadata should reflect the model that was actually used, not a stale hardcoded default — this was confusing for clients/tools that read the model field to know what answered them.

Testing

  • go build ./... and go vet ./... pass.
  • Verified locally: requesting "model": "claude-opus-5" now returns "model":"claude-opus-5" in the response (previously always returned claude-3-7-sonnet-20250219).

🤖 Generated with Claude Code

The OpenAI-compatible response model field was hardcoded to
"claude-3-7-sonnet-20250219" regardless of which model was requested
or actually used upstream, so clients would see e.g. a request for
"claude-opus-5" answered with a response claiming to be
claude-3-7-sonnet-20250219.

- Client now stores the original requested model (requestModel),
  captured before CreateConversation mutates c.model (e.g. stripping
  the "-think" suffix).
- model.ReturnOpenAIResponse takes a modelName parameter and both
  streamRespose and noStreamResponse use it for the response's
  "model" field instead of a hardcoded value, falling back to the
  old default only when no model name is available.
- go.mod: promote gopkg.in/yaml.v3 to a direct dependency, matching
  its direct import in config/config.go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant