mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:51:59 +00:00
Trivial additions (#63601)
Couple of trivial changes I teased out of some stacked PRs. - There were a couple of codepaths where we returned a non-200 in the Completions API but didn't have any logging statements. - Adds the `ProviderOverride::DisplayName` field. This will allow Sourcegraph admins who provide custom providers the ability to give them friendly names. (So that this information is available so it can be more useful than the raw ID.) Re: `ProviderOverride.DisplayName`, I don't expect this to be a required field. Or even used very often. But when debugging things, it seemed more helpful than just the opaque provider string like `anthropic-via-sourcegraph` or `anthropic-via-aws-bedrock`. ## Test plan NA ## Changelog NA
This commit is contained in:
parent
9ecc6e9444
commit
5e516faa2b
@ -85,12 +85,15 @@ func newCompletionsHandler(
|
||||
}
|
||||
|
||||
var version types.CompletionsVersion
|
||||
versionParam := r.URL.Query().Get("api-version")
|
||||
if versionParam == "" {
|
||||
switch versionParam := r.URL.Query().Get("api-version"); versionParam {
|
||||
case "":
|
||||
version = types.CompletionsVersionLegacy
|
||||
} else if versionParam == "1" {
|
||||
case "1":
|
||||
version = types.CompletionsV1
|
||||
} else {
|
||||
default:
|
||||
logger.Warn(
|
||||
"blocking request because unrecognized CompletionsVersion API param",
|
||||
log.String("version", versionParam))
|
||||
http.Error(w, "Unsupported API Version (Please update your client)", http.StatusNotAcceptable)
|
||||
return
|
||||
}
|
||||
@ -110,6 +113,7 @@ func newCompletionsHandler(
|
||||
// JSON payload. And just have a zero-value CompletionRequestParameters, e.g. no prompt.
|
||||
var requestParams types.CodyCompletionRequestParameters
|
||||
if err := json.NewDecoder(r.Body).Decode(&requestParams); err != nil {
|
||||
logger.Warn("malformed CodyCompletionRequestParameters", log.Error(err))
|
||||
http.Error(w, "could not decode request body", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@ -55,7 +55,8 @@ type DefaultModelConfig struct {
|
||||
// ProviderOverride is how a Sourcegraph admin would describe a `Provider` within
|
||||
// the site-configuration.
|
||||
type ProviderOverride struct {
|
||||
ID ProviderID `json:"id"`
|
||||
ID ProviderID `json:"id"`
|
||||
DisplayName string `json:"displayName"`
|
||||
|
||||
ClientSideConfig *ClientSideProviderConfig `json:"clientSideConfig,omitempty"`
|
||||
ServerSideConfig *ServerSideProviderConfig `json:"serverSideConfig,omitempty"`
|
||||
|
||||
Loading…
Reference in New Issue
Block a user