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

Commit b0bb67b

Browse files
authored
Update the default Sourcegraph-supplied LLM models (#64281)
This PR sets the defaults for "Sourcegraph supplied LLM models". ## When will these "defaults" be used? These models will _only_ be used IFF the Sourcegraph instance is _explicitly_ using the newer "modelConfiguration" site configuration data. (And opts into using Sourcegraph-supplied LLM models.) If the Sourcegraph instance is using the older "completions" configuration blob, then _only_ the user-supplied models will be used. (Or, based on the specific defaults defined in the code for the completions provider.) ## What about Cody Free or Cody Pro? 😬 yeah, we're going to need to deal with that later. Currently Sourcegraph.com is _not_ using the newer "modelConfiguration" site configuration, and instead we have some hacks in the code to ignore the internal modelconfig. See this "super-shady hack": https://github.com/sourcegraph/sourcegraph/blob/e5178a6bc0e0f2f5208f9dedb0c226661c881d98/cmd/frontend/internal/httpapi/completions/get_model.go#L425-L455 So we are just erring on the side of having Cody Free / Cody Pro "do whatever they do now", and this PR won't have any impact on that. We _do_ want Sourcegraph.com to only return this data, but there are a few things we need to get straightened out first. (e.g. Cody Gateway being ware of mrefs, and having Cody Clients no longer using `dotcom.ts` to hard-code Cody Pro LLM models.) ## What does this PR actually _do_? 1. It updates the code in `cmd/cody-gateway-config` so that it will produce a new "supported-models.json" file. 2. I then ran the tool manually, the output of which was then written to `internal/modelconfig/embedded/models.json`. 3. That's it. For any Sourcegraph releases after this PR gets merged, the "Sourcegraph supplied LLM models" will be the newer set defined in `models.json`. (i.e. having these new defaults, and including "fireworks::v1::starcoder".) ## Test plan ~~I tested things locally, and unfortunately it doesn't look like any clients are filtering based on the model capabilities. So "StarCoder" is showing up in the Cody Web UI, despite failing at runtime.~~ Update: This was a problem on my end. This isn't an issue. ## Changelog NA?
1 parent ee93777 commit b0bb67b

File tree

6 files changed

+80
-14
lines changed

6 files changed

+80
-14
lines changed

cmd/cody-gateway-config/dotcom_models.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ var (
1818
types.ModelCapabilityAutocomplete,
1919
types.ModelCapabilityChat,
2020
}
21+
editOnly = []types.ModelCapability{
22+
types.ModelCapabilityAutocomplete,
23+
}
2124

2225
// Standard context window sizes.
2326
standardCtxWindow = types.ContextWindow{
@@ -145,6 +148,42 @@ func getAnthropicModels() []types.Model {
145148
}
146149
}
147150

151+
func getFireworksModels() []types.Model {
152+
// https://docs.fireworks.ai/api-reference/post-completions
153+
const fireworksV1 = "fireworks::v1"
154+
155+
return []types.Model{
156+
// https://huggingface.co/blog/starcoder
157+
newModel(
158+
modelIdentity{
159+
MRef: mRef(fireworksV1, "starcoder"),
160+
// NOTE: This model name is virtualized.
161+
//
162+
// When Cody Gateway receives a request using model
163+
// "fireworks/starcoder", it will then pick a specialized
164+
// model name such as "starcoder2-15b" or "starcoder-7b".
165+
Name: "starcoder",
166+
DisplayName: "StarCoder",
167+
},
168+
modelMetadata{
169+
Capabilities: editOnly,
170+
Category: types.ModelCategorySpeed,
171+
Status: types.ModelStatusStable,
172+
Tier: types.ModelTierPro,
173+
},
174+
types.ContextWindow{
175+
// These values are much lower than other, text-centric models. We are
176+
// erring on the side of matching the token limits defined on the client
177+
// today. (And maybe the StarCoder is able to use a more efficient
178+
// tokenizer, because it's not processing many languages.)
179+
// https://github.com/sourcegraph/cody/blob/066d9c6ff48beb96a834f17021affc4e62094415/vscode/src/completions/providers/fireworks.ts#L132
180+
// https://github.com/sourcegraph/cody/blob/066d9c6ff48beb96a834f17021affc4e62094415/vscode/src/completions/providers/get-completion-params.ts#L5
181+
MaxInputTokens: 2048,
182+
MaxOutputTokens: 256,
183+
}),
184+
}
185+
}
186+
148187
func getGoogleModels() []types.Model {
149188
const (
150189
// Gemini API versions.
@@ -279,6 +318,7 @@ func GetCodyFreeProModels() ([]types.Model, error) {
279318
// ================================================
280319
var allModels []types.Model
281320
allModels = append(allModels, getAnthropicModels()...)
321+
allModels = append(allModels, getFireworksModels()...)
282322
allModels = append(allModels, getGoogleModels()...)
283323
allModels = append(allModels, getMistralModels()...)
284324
allModels = append(allModels, getOpenAIModels()...)

cmd/cody-gateway-config/main.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ var (
2727
func main() {
2828
flag.Parse()
2929

30+
liblog := log.Init(log.Resource{
31+
Name: "Cody Gateway Configuration App",
32+
})
33+
defer liblog.Sync()
34+
3035
logger := log.Scoped("cody-gateway-config")
3136

3237
// Generate the configuration.
@@ -88,9 +93,9 @@ func GenerateModelConfigurationDoc() (*types.ModelConfiguration, error) {
8893
Models: dotcomModels,
8994

9095
DefaultModels: types.DefaultModels{
91-
Chat: types.ModelRef("anthropic::2023-06-01::claude-3-sonnet"),
92-
CodeCompletion: types.ModelRef("anthropic::2023-06-01::claude-3-sonnet"),
93-
FastChat: types.ModelRef("anthropic::2023-06-01::claude-3-sonnet"),
96+
Chat: types.ModelRef("anthropic::2023-06-01::claude-3.5-sonnet"),
97+
CodeCompletion: types.ModelRef("fireworks::v1::starcoder"),
98+
FastChat: types.ModelRef("anthropic::2023-06-01::claude-3-haiku"),
9499
},
95100
}
96101

cmd/cody-gateway-config/providers.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ func GetProviders() ([]types.Provider, error) {
1212
// ================================================
1313
allProviders := []types.Provider{
1414
newProvider("anthropic", "Anthropic"),
15+
newProvider("fireworks", "Fireworks"),
1516
newProvider("google", "Google"),
16-
newProvider("mistral", "Mistral"),
1717
newProvider("openai", "OpenAI"),
18+
19+
// Special case, as mistral models will get
20+
// served via our Fireworks integration.
21+
newProvider("mistral", "Mistral"),
1822
}
1923

2024
// Validate the Provider data.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func TestCodyProModelAllowlists(t *testing.T) {
263263
}
264264
}
265265
if !supportsChat {
266-
t.Logf("NA. Skipping model %q as it does not support chat.", sourcegraphSuppliedModel.ModelRef)
266+
t.Skipf("NA. Skipping model %q as it does not support chat.", sourcegraphSuppliedModel.ModelRef)
267267
}
268268

269269
legacyModelRef := toLegacyMRef(sourcegraphSuppliedModel.ModelRef)

internal/modelconfig/embedded/models.json

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
"displayName": "Anthropic"
88
},
99
{
10-
"id": "google",
11-
"displayName": "Google"
10+
"id": "fireworks",
11+
"displayName": "Fireworks"
1212
},
1313
{
14-
"id": "mistral",
15-
"displayName": "Mistral"
14+
"id": "google",
15+
"displayName": "Google"
1616
},
1717
{
1818
"id": "openai",
1919
"displayName": "OpenAI"
20+
},
21+
{
22+
"id": "mistral",
23+
"displayName": "Mistral"
2024
}
2125
],
2226
"models": [
@@ -111,6 +115,19 @@
111115
"maxOutputTokens": 4000
112116
}
113117
},
118+
{
119+
"modelRef": "fireworks::v1::starcoder",
120+
"displayName": "StarCoder",
121+
"modelName": "starcoder",
122+
"capabilities": ["autocomplete"],
123+
"category": "speed",
124+
"status": "stable",
125+
"tier": "pro",
126+
"contextWindow": {
127+
"maxInputTokens": 2048,
128+
"maxOutputTokens": 256
129+
}
130+
},
114131
{
115132
"modelRef": "google::v1::gemini-1.5-pro-latest",
116133
"displayName": "Gemini 1.5 Pro",
@@ -204,8 +221,8 @@
204221
}
205222
],
206223
"defaultModels": {
207-
"chat": "anthropic::2023-06-01::claude-3-sonnet",
208-
"fastChat": "anthropic::2023-06-01::claude-3-sonnet",
209-
"codeCompletion": "anthropic::2023-06-01::claude-3-sonnet"
224+
"chat": "anthropic::2023-06-01::claude-3.5-sonnet",
225+
"fastChat": "anthropic::2023-06-01::claude-3-haiku",
226+
"codeCompletion": "fireworks::v1::starcoder"
210227
}
211228
}

internal/modelconfig/validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ func ValidateModelConfig(cfg *types.ModelConfiguration) error {
163163
return errors.Errorf("unknown chat model %q", cfg.DefaultModels.Chat)
164164
}
165165
if !isKnownModel(cfg.DefaultModels.CodeCompletion) {
166-
return errors.Errorf("unknown chat model %q", cfg.DefaultModels.CodeCompletion)
166+
return errors.Errorf("unknown code completion model %q", cfg.DefaultModels.CodeCompletion)
167167
}
168168
if !isKnownModel(cfg.DefaultModels.FastChat) {
169-
return errors.Errorf("unknown chat model %q", cfg.DefaultModels.FastChat)
169+
return errors.Errorf("unknown fast chat model %q", cfg.DefaultModels.FastChat)
170170
}
171171

172172
return nil

0 commit comments

Comments
 (0)