This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Return model IDs from GraphQL, not model Names#64307
Merged
Conversation
emidoots
approved these changes
Aug 6, 2024
Member
emidoots
left a comment
There was a problem hiding this comment.
LGTM, I think this is the right fix. I dug around the client codebase and didn't find any dependency on the colon so I think we're in the clear.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
::sigh:: the problem here is super in the weeds, but ultimately this fixes a problem introduced when using AWS Bedrock and Sourcegraph instances using the older style "completions" config.
The problem
AWS Bedrock has some LLM model names that contain a colon, e.g.
anthropic.claude-3-opus-20240229-v1:0. Cody clients connecting to Sourcegraph instances using the older style "completions" config will obtain the available LLM models by using GraphGL.So the Cody client would see that the chat model is
anthropic.claude-3-opus-20240229-v1:0.However, under the hood, the Sourcegraph instance will convert the site config into the newer
modelconfigformat. And during that conversion, we use a different value for the model ID than what is in the site config. (The model name is what is sent to the LLM API, and is unmodified. The model ID is a stable, unique identifier but is sanitized so that it adheres to naming rules.)Because of this, we have a problem.
When the Cody client makes a request to the HTTP completions API with the model name of
anthropic.claude-3-opus-20240229-v1:0oranthropic/anthropic.claude-3-opus-20240229-v1:0it fails. Because there is no model with ID...v1:0. (We only have the sanitized version,...v1_0.)The fix
There were a few ways we could fix this, but this goes with just having the GraphQL component return the model ID instead of the model name. So that when the Cody client passes that model ID to the completions API, everything works as it should.
And, practically speaking, for 99.9% of cases, the model name and model ID will be identical. We only strip out non-URL safe characters and colons, which usually aren't used in model names.
Potential bugs
With this fix however, there is a specific combination of { client, server, and model name } where things could in theory break. Specifically:
Fixes PRIME-464.
Test plan
Added some unit tests.
Changelog
NA