mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
[feature] Filter providers on save
This commit is contained in:
@ -81,7 +81,7 @@ const sandbox = {
|
||||
connectionAndInactivity: cfgAiApiTimeout,
|
||||
wholeCycle: cfgAiApiTimeout
|
||||
};
|
||||
//console.log("fetch", url, options);
|
||||
ctx.logger.debug("engineWrapper fetch", url, options);
|
||||
return utils.httpRequest(
|
||||
sandbox.ctx,
|
||||
method,
|
||||
|
||||
@ -238,7 +238,7 @@ async function processProvider(ctx, provider) {
|
||||
aiEngine.setCtx(ctx);
|
||||
await AI.getModels(provider);
|
||||
// Process result
|
||||
if (AI.TmpProviderForModels.models) {
|
||||
if (AI.TmpProviderForModels?.models) {
|
||||
engineModels = AI.TmpProviderForModels.models;
|
||||
engineModelsUI = AI.TmpProviderForModels.modelsUI;
|
||||
}
|
||||
|
||||
@ -52,9 +52,17 @@
|
||||
onInit(tmp[i]);
|
||||
}
|
||||
});
|
||||
AIIntegration.onSave = async function() {
|
||||
const config = {aiSettings: settings};
|
||||
return await putConfig(config).then(function() {
|
||||
AIIntegration.onSave = function() {
|
||||
var settingsFiltered = Object.assign({}, settings);
|
||||
if (settingsFiltered.providers) {
|
||||
for (var id in settingsFiltered.providers) {
|
||||
if (settingsFiltered.providers.hasOwnProperty(id)) {
|
||||
settingsFiltered.providers[id].models = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
var config = {aiSettings: settingsFiltered};
|
||||
return putConfig(config).then(function() {
|
||||
return true;
|
||||
}).catch(function() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user