👮 fix(enforceModelSpec): handle nested objects (#2681)

This commit is contained in:
Danny Avila 2024-05-12 18:20:53 -04:00 committed by GitHub
parent c83d9d61d4
commit 89899164ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 71 additions and 4 deletions

View file

@ -42,6 +42,15 @@ async function buildEndpointOption(req, res, next) {
return handleError(res, { text: 'Model spec mismatch' });
}
if (
currentModelSpec.preset.endpoint !== EModelEndpoint.gptPlugins &&
currentModelSpec.preset.tools
) {
return handleError(res, {
text: `Only the "${EModelEndpoint.gptPlugins}" endpoint can have tools defined in the preset`,
});
}
const isValidModelSpec = enforceModelSpec(currentModelSpec, parsedBody);
if (!isValidModelSpec) {
return handleError(res, { text: 'Model spec mismatch' });