ai: extra user models fix from main

This commit is contained in:
end-4
2026-03-14 21:57:04 +01:00
parent da7bddf1d1
commit 79fe2651cc
+12 -5
View File
@@ -305,14 +305,18 @@ Singleton {
} }
property ApiStrategy currentApiStrategy: apiStrategies[models[currentModelId]?.api_format || "openai"] property ApiStrategy currentApiStrategy: apiStrategies[models[currentModelId]?.api_format || "openai"]
function addUserModels() {
(Config?.options.ai?.extraModels ?? []).forEach(model => {
const safeModelName = root.safeModelName(model["model"]);
root.addModel(safeModelName, model)
});
}
Connections { Connections {
target: Config target: Config
function onReadyChanged() { function onReadyChanged() {
if (!Config.ready) return; if (!Config.ready) return;
(Config?.options.ai?.extraModels ?? []).forEach(model => { root.addUserModels()
const safeModelName = root.safeModelName(model["model"]);
root.addModel(safeModelName, model)
});
} }
} }
@@ -321,6 +325,7 @@ Singleton {
Component.onCompleted: { Component.onCompleted: {
setModel(currentModelId, false, false); // Do necessary setup for model setModel(currentModelId, false, false); // Do necessary setup for model
root.addUserModels()
} }
function guessModelLogo(model) { function guessModelLogo(model) {
@@ -345,7 +350,9 @@ Singleton {
} }
function addModel(modelName, data) { function addModel(modelName, data) {
root.models[modelName] = aiModelComponent.createObject(this, data); root.models = Object.assign({}, root.models, {
[modelName]: aiModelComponent.createObject(this, data)
});
} }
Process { Process {