Add unit test for modelconfig converting starcoder completion model (#64160)

There was some confusion about how a starcoder model would "come out" of
the modelconfig system. Added a unit test and some clarifying comments
to hopefully help out.

## Test plan

Just add tests for the sake of clarifying the code.

## Changelog

NA
This commit is contained in:
Chris Smith 2024-07-30 13:00:26 -07:00 committed by GitHub
parent 84e28998e9
commit 3b3749f559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -398,4 +398,31 @@ func TestConvertCompletionsConfig(t *testing.T) {
}
})
})
t.Run("Starcoder", func(t *testing.T) {
compConfig := loadCompletionsConfig(schema.Completions{
Provider: "sourcegraph",
CompletionModel: "fireworks/starcoder",
})
require.NotNil(t, compConfig)
siteModelConfig, err := convertCompletionsConfig(compConfig)
require.NoError(t, err)
// DefaultModels. Claude is used for chat, but the code completions were explicitly set
// to StarCoder.
require.NotNil(t, siteModelConfig.DefaultModels)
assert.EqualValues(t, "anthropic::unknown::claude-3-sonnet-20240229", siteModelConfig.DefaultModels.Chat)
assert.EqualValues(t, "fireworks::unknown::starcoder", siteModelConfig.DefaultModels.CodeCompletion)
assert.EqualValues(t, "anthropic::unknown::claude-3-haiku-20240307", siteModelConfig.DefaultModels.FastChat)
// We set the modle's name to just "starcoder" because that's all the information we have
// available. But on the Cody Gateway side, it is virtualized. And will actually use a
// "real" model name like "starcoder2-7b" when resolving the request.
//
// See `pickStarCoderModel` in the Cody Gateway code.
scModel := siteModelConfig.ModelOverrides[2]
assert.EqualValues(t, "fireworks::unknown::starcoder", scModel.ModelRef)
assert.EqualValues(t, "starcoder", scModel.ModelName)
})
}