Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

bring back the keyOptions in getUserLLMModels()

Forhad Hosaindcbb2f2cc725
diff --git a/packages/app/src/backend/services/LLMHelper/index.ts b/packages/app/src/backend/services/LLMHelper/index.ts
index d98a999d..de83fa08 100644
--- a/packages/app/src/backend/services/LLMHelper/index.ts
+++ b/packages/app/src/backend/services/LLMHelper/index.ts
@@ -39,14 +39,26 @@ async function getUserLLMModels(req: Request) {
modelTpl.tags.push('alias: ' + modelTpl.alias);
}
+ // #region: Legacy keyOptions handling
+ // TODO: We will clean up `keyOptions` in the future but keep it for legacy users.
+
+ const modelKeyOptions = modelTpl.keyOptions || {};
+ delete modelTpl.keyOptions;
+
+ const provider = modelTpl?.provider?.toLowerCase();
+ const hasAPIKey = !!keys[provider?.toLowerCase()];
+
+ if (hasAPIKey) {
+ modelTpl = { ...modelTpl, ...modelKeyOptions }; //override the model config with the key config
+ modelTpl.hasKey = true;
+ }
+ // #endregion
+
let enabled =
typeof LLMModels[modelEntryId].enabled === 'function'
? LLMModels[modelEntryId].enabled({ user: req.user, team: req._team })
: modelTpl.enabled;
- const provider = modelTpl?.provider?.toLowerCase();
- const hasAPIKey = !!keys[provider?.toLowerCase()];
-
// If the credentials are only 'vault' and the team doesn't have their own API key, disable the model.
if (modelTpl.credentials === 'vault' && !hasAPIKey) {
enabled = false;