feat: add OpenCode Go provider and support for custom models
- Introduced OpenCode Go provider with relevant configurations. - Enhanced model management by allowing users to add and delete custom models. - Updated UI components to support model selection for image types. - Adjusted sidebar visibility to include image media kinds.
This commit is contained in:
@@ -44,6 +44,7 @@ function cloneDefaultData() {
|
||||
providerNodes: [],
|
||||
proxyPools: [],
|
||||
modelAliases: {},
|
||||
customModels: [],
|
||||
mitmAlias: {},
|
||||
combos: [],
|
||||
apiKeys: [],
|
||||
@@ -515,6 +516,33 @@ export async function deleteModelAlias(alias) {
|
||||
await safeWrite(db);
|
||||
}
|
||||
|
||||
// Custom models — user-added models with explicit type (llm/image/tts/embedding/...)
|
||||
export async function getCustomModels() {
|
||||
const db = await getDb();
|
||||
return db.data.customModels || [];
|
||||
}
|
||||
|
||||
export async function addCustomModel({ providerAlias, id, type = "llm", name }) {
|
||||
const db = await getDb();
|
||||
if (!db.data.customModels) db.data.customModels = [];
|
||||
const exists = db.data.customModels.some(
|
||||
(m) => m.providerAlias === providerAlias && m.id === id && (m.type || "llm") === type
|
||||
);
|
||||
if (exists) return false;
|
||||
db.data.customModels.push({ providerAlias, id, type, name: name || id });
|
||||
await safeWrite(db);
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function deleteCustomModel({ providerAlias, id, type = "llm" }) {
|
||||
const db = await getDb();
|
||||
if (!db.data.customModels) return;
|
||||
db.data.customModels = db.data.customModels.filter(
|
||||
(m) => !(m.providerAlias === providerAlias && m.id === id && (m.type || "llm") === type)
|
||||
);
|
||||
await safeWrite(db);
|
||||
}
|
||||
|
||||
export async function getMitmAlias(toolName) {
|
||||
const db = await getDb();
|
||||
const all = db.data.mitmAlias || {};
|
||||
|
||||
Reference in New Issue
Block a user