Repository navigation
fix: echo the actually-used model in chat completion responses - #41
Open
hadooptofly wants to merge 1 commit into
Open
hadooptofly wants to merge 1 commit into
hadooptofly wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The OpenAI-compatible response's
modelfield was hardcoded toclaude-3-7-sonnet-20250219regardless of which model was actually requested/used, so a request for e.g.claude-opus-5would come back with"model":"claude-3-7-sonnet-20250219"even though the reply content itself was genuinely answered by the requested model.Clientnow stores the originally requested model inrequestModel, captured inNewClientbeforeCreateConversationmutatesc.model(e.g. stripping the-thinksuffix).model.ReturnOpenAIResponsenow takes amodelNameparameter; bothstreamResposeandnoStreamResponseuse 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: promotedgopkg.in/yaml.v3to a direct dependency to match its direct import inconfig/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
modelfield to know what answered them.Testing
go build ./...andgo vet ./...pass."model": "claude-opus-5"now returns"model":"claude-opus-5"in the response (previously always returnedclaude-3-7-sonnet-20250219).🤖 Generated with Claude Code