You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.0 KiB
33 lines
1.0 KiB
import { defineWrappedResponseHandler } from "#server/utils/handler";
|
|
import { R } from "#server/utils/response";
|
|
import { getConfigGlobal } from "#server/utils/context";
|
|
import { listSystemModels, getModelWithProviderByIdAny } from "#server/service/llm";
|
|
|
|
export default defineWrappedResponseHandler(async () => {
|
|
const systemModels = await listSystemModels();
|
|
const defaultModelId = await getConfigGlobal("agentDefaultModelId");
|
|
|
|
const list = systemModels.map((m) => ({
|
|
id: m.id,
|
|
name: m.name,
|
|
modelId: m.modelId,
|
|
providerName: "—",
|
|
}));
|
|
|
|
if (defaultModelId) {
|
|
const exists = list.some((m) => m.id === defaultModelId);
|
|
if (!exists) {
|
|
const row = await getModelWithProviderByIdAny(defaultModelId);
|
|
if (row) {
|
|
list.unshift({
|
|
id: row.model.id,
|
|
name: row.model.name,
|
|
modelId: row.model.modelId,
|
|
providerName: row.provider.name,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
return R.success({ list, defaultModelId: defaultModelId ?? null });
|
|
});
|
|
|