-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix: Ensure Default ModelSpecs Are Set Correctly (#5218)
* 🐛 fix: default modelSpecs not being set * feat: Add imageDetail parameter for OpenAI endpoints in tQueryParamsSchema * feat: Implement processModelSpecs function to enhance model specs processing from configuration * feat: Refactor configuration schemas and types for improved structure and clarity * feat: Add append_current_datetime parameter to tQueryParamsSchema for enhanced endpoint functionality * fix: Add endpointType to getSaveOptions and enhance endpoint handling in Settings component * fix: Change endpointType to be nullable and optional in tConversationSchema for improved flexibility * fix: allow save & submit for google endpoint
- Loading branch information
1 parent
916faf6
commit 69a9b8b
Showing
15 changed files
with
201 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { EModelEndpoint } = require('librechat-data-provider'); | ||
const { normalizeEndpointName } = require('~/server/utils'); | ||
const { logger } = require('~/config'); | ||
|
||
/** | ||
* Sets up Model Specs from the config (`librechat.yaml`) file. | ||
* @param {TCustomConfig['endpoints']} endpoints - The loaded custom configuration for endpoints. | ||
* @param {TCustomConfig['modelSpecs'] | undefined} [modelSpecs] - The loaded custom configuration for model specs. | ||
* @returns {TCustomConfig['modelSpecs'] | undefined} The processed model specs, if any. | ||
*/ | ||
function processModelSpecs(endpoints, _modelSpecs) { | ||
if (!_modelSpecs) { | ||
return undefined; | ||
} | ||
|
||
/** @type {TCustomConfig['modelSpecs']['list']} */ | ||
const modelSpecs = []; | ||
/** @type {TCustomConfig['modelSpecs']['list']} */ | ||
const list = _modelSpecs.list; | ||
|
||
const customEndpoints = endpoints[EModelEndpoint.custom] ?? []; | ||
|
||
for (const spec of list) { | ||
if (EModelEndpoint[spec.preset.endpoint] && spec.preset.endpoint !== EModelEndpoint.custom) { | ||
modelSpecs.push(spec); | ||
continue; | ||
} else if (spec.preset.endpoint === EModelEndpoint.custom) { | ||
logger.warn( | ||
`Model Spec with endpoint "${spec.preset.endpoint}" is not supported. You must specify the name of the custom endpoint (case-sensitive, as defined in your config). Skipping model spec...`, | ||
); | ||
continue; | ||
} | ||
|
||
const normalizedName = normalizeEndpointName(spec.preset.endpoint); | ||
const endpoint = customEndpoints.find( | ||
(customEndpoint) => normalizedName === normalizeEndpointName(customEndpoint.name), | ||
); | ||
|
||
if (!endpoint) { | ||
logger.warn(`Model spec with endpoint "${spec.preset.endpoint}" was skipped: Endpoint not found in configuration. The \`endpoint\` value must exactly match either a system-defined endpoint or a custom endpoint defined by the user. | ||
For more information, see the documentation at https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/model_specs#endpoint`); | ||
continue; | ||
} | ||
|
||
modelSpecs.push({ | ||
...spec, | ||
preset: { | ||
...spec.preset, | ||
endpoint: normalizedName, | ||
}, | ||
}); | ||
} | ||
|
||
return { | ||
..._modelSpecs, | ||
list: modelSpecs, | ||
}; | ||
} | ||
|
||
module.exports = { processModelSpecs }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.