Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Cody Gateway: New Claude 3.5 Sonnet model#63395

Merged
abeatrix merged 2 commits into
mainfrom
bee/sonnet-3.5-model
Jun 20, 2024
Merged

Cody Gateway: New Claude 3.5 Sonnet model#63395
abeatrix merged 2 commits into
mainfrom
bee/sonnet-3.5-model

Conversation

@abeatrix

@abeatrix abeatrix commented Jun 20, 2024

Copy link
Copy Markdown
Contributor

CONTEXT: https://sourcegraph.slack.com/archives/C05AGQYD528/p1718898110684289?thread_ts=1718896254.676939&cid=C05AGQYD528

CLOSE https://linear.app/sourcegraph/issue/CODY-2177

Adding new Claude 3.5 Sonnet (claude-3.5-sonnet-20240620) to the Cody Gateway allow list.

Model ID based on Anthropic Console:

image

Claude 3.5 Sonnet is Live on s0.dev to confirm this is the correct model ID

Test plan

Verify you can use the new model through Cody Gateway

Changelog

feature(plg): new Claude 3.5 Sonnet model support for Cody Pro users

@chrsmith chrsmith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes looks good to me, but before you submit could you please run go test ./internal/modelconfig and confirm that those unit tests pass?

The intention was that it would confirm that all provider and model IDs adhere to strict naming rules. So either (1) the tests aren't being run or (2) the logic/implementation is wrong, and allowing this to pass.

This isn't related to your specific change, so if you are rushing to get this out just merge this as-is and I can follow up with that later. (Since even if the models.json file is corrupted, it won't impact anything right now.)

i.e. this test, right here:
https://github.com/sourcegraph/sourcegraph/blob/b05bd5bb16ca89928d060b1574f51e5d765657a0/internal/modelconfig/validation_test.go#L42-L45

// Pro Anthropic models.
newModel(
modelIdentity{
MRef: mRef(anthropic_06_2023, "claude-3.5-sonnet"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fail the unit tests. So if CI/CD isn't unhappy with this change, something is amiss.

Did you run go test ./internal/modelconfig/, and what did it say? (I assumed it the relevant tests would be ran automatically, but perhaps not?)

Anyways, the ModelID here "claude-3.5-sonnet" would fail the regular expression defined over in:
https://github.com/sourcegraph/sourcegraph/blob/main/internal/modelconfig/validation.go#L19

However, this seems like a reasonable enough change (allowing '.') that we should just update the regular expression for resource IDs.

⚠️ This would be a major no-no after we ship the server-side-model-config stuff, as it would be a change that would break downstream Sourcegraph instances. But since it hasn't actually shipped yet, updating the validation logic is A-OK.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's passing 👀

sourcegraph on  bee/sonnet-3.5-model via 🐹 v1.22.4 via  v20.8.1 on ☁️  (us-west-1) on ☁️  beatrix@sourcegraph.com 
❯ go test ./internal/modelconfig/
ok      github.com/sourcegraph/sourcegraph/internal/modelconfig 0.238s

Should we tickle this in a follow-up issue instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrsmith If I understand it correctly, the linked regex should not only fail for claude-3.5-sonnet but also claude-3-sonnet, since it doesn't capture the dashes...?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I wasn't clearer. The dashes aren't the problem, it's the period in "3.5". If the regex is [a-z][a-z-]*[a-z] HOW IS THAT ALLOWED?!?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OHHHH this is why based on Cody:
In Go, a hyphen in a character class is interpreted as a range operator, not a literal hyphen. So, [a-z-] is equivalent to [a-z-] or [a-z\w]. This means that the regex is actually matching any word character (letters, numbers, or underscores) in addition to hyphens.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#TIL 🙏

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAME

const Claude3Haiku = "claude-3-haiku-20240307"
const Claude3Sonnet = "claude-3-sonnet-20240229"
const Claude3Opus = "claude-3-opus-20240229"
const Claude35Sonnet = "claude-3.5-sonnet-20240620"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: There isn't a right or wrong way to name this. But FWIW, I've seen code bases that used an underscore where a period would be for readability. e.g. Claude3_5Sonnet. Or perhaps Claude3point5Sonnet or similar.

🤷 This looks weird ("Claude 35"), but I have no suggestion for how to improve it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the format we are using for Gemini too but i agree it looks weird. Will look into it in a follow-up PR and unify them!

@abeatrix abeatrix merged commit 18c7ba8 into main Jun 20, 2024
@abeatrix abeatrix deleted the bee/sonnet-3.5-model branch June 20, 2024 16:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants