modelconfig: handle converting site config JSON -> internal data types#63706
Conversation
This causes the `modelconfig` package to actually begin converting the new `"modelConfiguration"` site config which was introduced in #63654 into the internal data types we use for model configuration. This is all pretty straightforward / lame type conversion code, but carefully written to preserve all the semantics we care about. Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
chrsmith
left a comment
There was a problem hiding this comment.
This is fine to get off the ground, but I am confident we'll want to rework the code around the recommendedSettings map[types.ModelRef]types.ModelOverride type, since it seems like the only thing we are really adding beyond the display name is the context window. And so we can probably cut down on a lot of the boiler plate. (But what you have here is fine to start, if we only are concerned about a dozen or so models.)
| // This function is responsible for converting the schema.SiteConfiguration that admins write | ||
| // into our internal data type. | ||
| func getSiteModelConfigurationOrNil(logger log.Logger, siteConfig schema.SiteConfiguration) (*types.SiteModelConfiguration, error) { | ||
| // If "modelConfiguration" is specified, then we respect that and only that. If it is not specified, |
There was a problem hiding this comment.
I haven't looked at your other PRs, but did we add any "site config validation" logic to return an error if both forms of configuration are adding? If not, just to confirm, we would want to do that, right? Since having both types of config specified would be super-confusing?
There was a problem hiding this comment.
That's right, I haven't added any site config validation logic yet. I do have it on my TODO to do in the coming days though.
There was a problem hiding this comment.
JFYI, I think we really do want to lean on the internal/modelconfig validation routines to ensure that the overall internal/modelconfig/types.ModelConfiguration type is well-formed.
Since otherwise, it's too easy to have confusing things break at runtime that would much easier be described as invalid configuration settings. We do that for the CompletionsProvider config codepath. But we can ship without it for ~today.
There was a problem hiding this comment.
I agree; my thinking was that site config validation ('you cannot save your configuration, there was an error:') would consist of two things:
- Confirming that you did not specify both
"completions"and the new"modelConfiguration"at the same time. - Confirming that you did not list the same mref in both
modelOverridesandmodelOverridesRecommendedSettings(explained in site config: minor fixes, make modelConfiguration enable new backend models API, initial self-hosted model config #63697) - Assuming the above two are not issues, running the converted configuration through the
internal/modelconfigvalidation routines and yielding any errors it finds.
Co-authored-by: Chris Smith <chrsmith@users.noreply.github.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Signed-off-by: Stephen Gutekanst <stephen@sourcegraph.com>
Yeah, I agree - I foresee this logic changing a good amount. The types I wrote out here right now are just stubs and I suspect that they will actually differ a fair amount once I get to actual testing with them |
This causes the
modelconfigpackage to actually begin converting the new"modelConfiguration"site config which was introduced in #63654 into the internal data types we use for model configuration.This is all pretty straightforward / lame type conversion code, but carefully written to preserve all the semantics we care about.
Test plan
Written very carefully, and confirmed that this query:
returns what I would expect with this site configuration:
site config
We could certainly use more unit tests here to prevent potential future regressions, I can add those in a future PR.
Changelog
Has no effect on users unless they opt into the early-access
"modelConfiguration"site config feature.