pass ModelConfigInfo down to client.Get() for self-hosted-models#63739
Conversation
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
| // Using the new "modelConfiguration" site config | ||
| // TODO(slimsag): self-hosted-models: this logic only handles Cody Enterprise with Self-hosted models | ||
| // Only in this case do we have modelConfigInfo != nil | ||
| return nil, errors.Newf("TODO: implement self-hosted-models") |
There was a problem hiding this comment.
This is all in service of having modelConfigInfo right here.
chrsmith
left a comment
There was a problem hiding this comment.
I have suggestions for how we can rewrite the logic within getModel to be clearer. But given that I'll rewrite the function entirely in XX hours, I wouldn't worry too much about it. :D
| if modelConfig := conf.Get().SiteConfig().ModelConfiguration; modelConfig != nil { | ||
| // Using new "modelConfiguration" site config. | ||
| // TODO(slimsag): self-hosted-models: currently this logic only handles Cody Enterprise with Self-hosted models | ||
| if err := modelconfig.ValidateModelRef(modelconfigtypes.ModelRef(requestParams.Model)); err != nil { |
There was a problem hiding this comment.
This code seems a little hard to follow since you're essentially adding fallback options in case there is an error. So what do you think about inverting the error condition so this is a little easier to follow, e.g.:
// WDYT of using 'modelconfigSDK' rather than 'modelconfigtypes'?
import modelconfigSDK ".../types"
// Check if the user supplied a valid ModelRef.
if requestParams.Model != "" {
mref := modelconfigSDK.ModelRef(requestParams.Model)
if err := modelconfig.ValidateModelRef(mref); err == nil {
return requestParams.Model, nil
}
}
// Fallback to using the default models as per the configuration.
modelConfig, err := frontendmodelconfig.Get().Get()
if err != nil {
return "", err
}
return string(modelConfig.DefaultModels.CodeCompletion), nil| modelConfig, err := modelconfig.Get().Get() | ||
| if err != nil { | ||
| http.Error(w, err.Error(), http.StatusInternalServerError) | ||
| return |
There was a problem hiding this comment.
For both of these 500 return paths, we use logger.Error(...). Since otherwise it'll be a pain to debug or troubleshoot any issues users run into.
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
This PR has a single goal: pass a new
ModelConfigInfotype, which has theProviderandModelwe should use to serve a completions request, down intoclient.Get()This PR explicitly only handles the case we care about for Self-hosted models, and all pieces of logic that I expect will be replaced/superseded by your work @chrsmith are annotated with
// TODO(slimsag): self-hosted-models:comments so we can easily find and remove them when your work is ready.Every location I have modified has been carefully wrapped in an if statement like
if conf.Get().SiteConfig().ModelConfiguration != nilto ensure that this change only affects people who set the new"modelConfiguration"site config property.Test plan
"modelConfiguration"and removed"completions"in my dev instances' site config.TODOerror back:Changelog
N/A