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

Commit 18c7ba8

Browse files
authored
Cody Gateway: New Claude 3.5 Sonnet model (#63395)
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](https://github.com/sourcegraph/sourcegraph/assets/68532117/6f27b24f-a7f5-4b3f-85a9-c0eed1babe9b) Claude 3.5 Sonnet is Live on [s0.dev](http://s0.dev/) to confirm this is the correct model ID <!-- 💡 To write a useful PR description, make sure that your description covers: - WHAT this PR is changing: - How was it PREVIOUSLY. - How it will be from NOW on. - WHY this PR is needed. - CONTEXT, i.e. to which initiative, project or RFC it belongs. The structure of the description doesn't matter as much as covering these points, so use your best judgement based on your context. Learn how to write good pull request description: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4 --> ## Test plan <!-- All pull requests REQUIRE a test plan: https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> Verify you can use the new model through Cody Gateway ## Changelog <!-- 1. Ensure your pull request title is formatted as: $type($domain): $what 2. Add bullet list items for each additional detail you want to cover (see example below) 3. You can edit this after the pull request was merged, as long as release shipping it hasn't been promoted to the public. 4. For more information, please see this how-to https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c? Audience: TS/CSE > Customers > Teammates (in that order). Cheat sheet: $type = chore|fix|feat $domain: source|search|ci|release|plg|cody|local|... --> <!-- Example: Title: fix(search): parse quotes with the appropriate context Changelog section: ## Changelog - When a quote is used with regexp pattern type, then ... - Refactored underlying code. --> feature(plg): new Claude 3.5 Sonnet model support for Cody Pro users
1 parent b05bd5b commit 18c7ba8

File tree

7 files changed

+64
-3
lines changed

7 files changed

+64
-3
lines changed

cmd/cody-gateway-config/dotcom_models.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,41 @@ func getAnthropicModels() []types.Model {
4646
)
4747

4848
return []types.Model{
49+
// Free Anthropic model.
4950
newModel(
5051
modelIdentity{
5152
MRef: mRef(anthropic_06_2023, "claude-3-sonnet"),
5253
Name: "claude-3-sonnet-20240229",
5354
DisplayName: "Claude 3 Sonnet",
5455
},
56+
modelMetadata{
57+
Capabilities: chatAndEdit,
58+
Category: types.ModelCategoryBalanced,
59+
Status: types.ModelStatusStable,
60+
Tier: types.ModelTierFree,
61+
},
62+
expandedCtxWindow),
63+
64+
// Pro Anthropic models.
65+
newModel(
66+
modelIdentity{
67+
MRef: mRef(anthropic_06_2023, "claude-3.5-sonnet"),
68+
Name: "claude-3.5-sonnet-20240620",
69+
DisplayName: "Claude 3.5 Sonnet",
70+
},
71+
modelMetadata{
72+
Capabilities: chatAndEdit,
73+
Category: types.ModelCategoryAccuracy,
74+
Status: types.ModelStatusStable,
75+
Tier: types.ModelTierPro,
76+
},
77+
expandedCtxWindow),
78+
newModel(
79+
modelIdentity{
80+
MRef: mRef(anthropic_06_2023, "claude-3-opus"),
81+
Name: "claude-3-opus-20240229",
82+
DisplayName: "Claude 3 Opus",
83+
},
5584
modelMetadata{
5685
Capabilities: chatAndEdit,
5786
Category: types.ModelCategoryAccuracy,
@@ -67,7 +96,7 @@ func getAnthropicModels() []types.Model {
6796
},
6897
modelMetadata{
6998
Capabilities: chatAndEdit,
70-
Category: types.ModelCategoryAccuracy,
99+
Category: types.ModelCategorySpeed,
71100
Status: types.ModelStatusStable,
72101
Tier: types.ModelTierPro,
73102
},

cmd/cody-gateway/shared/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func (c *Config) Load() {
235235
"claude-instant-1.2-cyan",
236236
anthropic.Claude3Haiku,
237237
anthropic.Claude3Sonnet,
238+
anthropic.Claude35Sonnet,
238239
anthropic.Claude3Opus,
239240
}, ","),
240241
"Anthropic models that can be used."))

cmd/frontend/internal/dotcom/productsubscription/codygateway_dotcom_user.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ func allowedModels(scope types.CompletionsFeature, isProUser bool) []string {
363363
chatModels := []string{
364364
"anthropic/" + anthropic.Claude3Haiku,
365365
"anthropic/" + anthropic.Claude3Sonnet,
366+
"anthropic/" + anthropic.Claude35Sonnet,
366367
"anthropic/" + anthropic.Claude3Opus,
367368
"fireworks/" + fireworks.Mixtral8x7bInstruct,
368369
"fireworks/" + fireworks.Mixtral8x22Instruct,

cmd/frontend/internal/httpapi/completions/get_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func isAllowedCustomChatModel(model string, isProUser bool) bool {
113113
case
114114
"anthropic/" + anthropic.Claude3Haiku,
115115
"anthropic/" + anthropic.Claude3Sonnet,
116+
"anthropic/" + anthropic.Claude35Sonnet,
116117
"anthropic/" + anthropic.Claude3Opus,
117118
"fireworks/" + fireworks.Mixtral8x7bInstruct,
118119
"fireworks/" + fireworks.Mixtral8x22Instruct,

internal/completions/client/anthropic/anthropic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
const Claude3Haiku = "claude-3-haiku-20240307"
1818
const Claude3Sonnet = "claude-3-sonnet-20240229"
1919
const Claude3Opus = "claude-3-opus-20240229"
20+
const Claude35Sonnet = "claude-3.5-sonnet-20240620"
2021

2122
func NewClient(cli httpcli.Doer, apiURL, accessToken string, viaGateway bool, tokenManager tokenusage.Manager) types.CompletionsClient {
2223

internal/conf/computed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ func anthropicDefaultMaxPromptTokens(model string) int {
12571257
return 100_000
12581258

12591259
}
1260-
if model == "claude-2" || model == "claude-2.0" || model == "claude-2.1" || model == "claude-v2" || model == anthropic.Claude3Haiku || model == anthropic.Claude3Opus || model == anthropic.Claude3Sonnet {
1260+
if model == "claude-2" || model == "claude-2.0" || model == "claude-2.1" || model == "claude-v2" || model == anthropic.Claude3Haiku || model == anthropic.Claude3Opus || model == anthropic.Claude3Sonnet || model == anthropic.Claude35Sonnet {
12611261
// TODO: Technically, v2 and v3 also uses a 100k/200k window respectively, but we should
12621262
// validate that returning 100k here is the right thing to do.
12631263
return 12_000

internal/modelconfig/embedded/models.json

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,34 @@
2626
"displayName": "Claude 3 Sonnet",
2727
"string": "claude-3-sonnet-20240229",
2828
"capabilities": ["chat", "edit"],
29+
"category": "balanced",
30+
"status": "stable",
31+
"tier": "free",
32+
"contextWindow": {
33+
"maxInputTokens": 30000,
34+
"maxOutputTokens": 4000
35+
}
36+
},
37+
{
38+
"modelId": "unknown",
39+
"modelRef": "anthropic::2023-06-01::claude-3.5-sonnet",
40+
"displayName": "Claude 3.5 Sonnet",
41+
"string": "claude-3.5-sonnet-20240620",
42+
"capabilities": ["chat", "edit"],
43+
"category": "accuracy",
44+
"status": "stable",
45+
"tier": "pro",
46+
"contextWindow": {
47+
"maxInputTokens": 30000,
48+
"maxOutputTokens": 4000
49+
}
50+
},
51+
{
52+
"modelId": "unknown",
53+
"modelRef": "anthropic::2023-06-01::claude-3-opus",
54+
"displayName": "Claude 3 Opus",
55+
"string": "claude-3-opus-20240229",
56+
"capabilities": ["chat", "edit"],
2957
"category": "accuracy",
3058
"status": "stable",
3159
"tier": "pro",
@@ -40,7 +68,7 @@
4068
"displayName": "Claude 3 Haiku",
4169
"string": "claude-3-haiku-20240307",
4270
"capabilities": ["chat", "edit"],
43-
"category": "accuracy",
71+
"category": "speed",
4472
"status": "stable",
4573
"tier": "pro",
4674
"contextWindow": {

0 commit comments

Comments
 (0)