forked from Shinonome/dots-hyprland
ai: refactor user model loading
This commit is contained in:
@@ -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,13 +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
|
||||||
// Load extra models from config (onReadyChanged may not fire if Config is already ready)
|
root.addUserModels() // Config onReadyChanged above might not fire if config is loaded before this service
|
||||||
if (Config?.options?.ai?.extraModels) {
|
|
||||||
Config.options.ai.extraModels.forEach(model => {
|
|
||||||
const safeModelName = root.safeModelName(model["model"]);
|
|
||||||
root.addModel(safeModelName, model)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function guessModelLogo(model) {
|
function guessModelLogo(model) {
|
||||||
|
|||||||
Reference in New Issue
Block a user