refactor: remove models snapshot feature and related code
- Remove models snapshot UI section from Models page - Delete models API route handler and related logic - Remove models store implementation and exports - Clean up internationalization messages for removed feature - Update main entry point exports to exclude models store
This commit is contained in:
@@ -11,7 +11,6 @@ import { handleCronRoutes } from './routes/cron';
|
||||
import { handleFileRoutes } from './routes/files';
|
||||
import { handleGatewayRoutes } from './routes/gateway';
|
||||
import { handleKnowledgeRoutes } from './routes/knowledge';
|
||||
import { handleModelRoutes } from './routes/models';
|
||||
import { handleProviderRoutes } from './routes/providers';
|
||||
import { handleSessionRoutes } from './routes/sessions';
|
||||
import { handleSkillRoutes } from './routes/skills';
|
||||
@@ -25,7 +24,6 @@ const routeHandlers: RouteHandler[] = [
|
||||
handleProviderRoutes,
|
||||
handleChannelRoutes,
|
||||
handleAgentRoutes,
|
||||
handleModelRoutes,
|
||||
handleCronRoutes,
|
||||
handleGatewayRoutes,
|
||||
handleKnowledgeRoutes,
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
import type { ProviderAccount } from '@runtime/lib/providers';
|
||||
import {
|
||||
DEFAULT_AGENT_ID,
|
||||
DEFAULT_MAIN_SESSION_SUFFIX,
|
||||
buildMainSessionKey,
|
||||
normalizeAgentId,
|
||||
type AgentSummary,
|
||||
} from '@runtime/lib/models';
|
||||
import type { HostApiContext } from '../context';
|
||||
import type { NormalizedHostApiRequest } from '../route-utils';
|
||||
import { ok } from '../route-utils';
|
||||
|
||||
function formatModelDisplay(modelRef: string | null | undefined, fallbackLabel: string): string {
|
||||
const trimmed = String(modelRef ?? '').trim();
|
||||
if (!trimmed) return fallbackLabel;
|
||||
|
||||
const parts = trimmed.split('/');
|
||||
return parts[parts.length - 1] || trimmed;
|
||||
}
|
||||
|
||||
function buildMainModel(defaultAccount: ProviderAccount | null): AgentSummary {
|
||||
return {
|
||||
id: DEFAULT_AGENT_ID,
|
||||
name: 'Main Model',
|
||||
isDefault: true,
|
||||
providerAccountId: defaultAccount?.id ?? null,
|
||||
modelRef: defaultAccount?.model ?? null,
|
||||
modelDisplay: formatModelDisplay(defaultAccount?.model, defaultAccount?.label || 'Unassigned'),
|
||||
mainSessionKey: buildMainSessionKey(DEFAULT_AGENT_ID, DEFAULT_MAIN_SESSION_SUFFIX),
|
||||
vendorId: defaultAccount?.vendorId ?? null,
|
||||
source: 'synthetic-main',
|
||||
};
|
||||
}
|
||||
|
||||
function buildProviderBackedModels(accounts: ProviderAccount[]): AgentSummary[] {
|
||||
const seen = new Set<string>();
|
||||
const summaries: AgentSummary[] = [];
|
||||
|
||||
for (const account of accounts) {
|
||||
const agentId = normalizeAgentId(account.id);
|
||||
if (seen.has(agentId) || agentId === DEFAULT_AGENT_ID) continue;
|
||||
seen.add(agentId);
|
||||
|
||||
summaries.push({
|
||||
id: agentId,
|
||||
name: account.label || agentId,
|
||||
isDefault: false,
|
||||
providerAccountId: account.id,
|
||||
modelRef: account.model ?? null,
|
||||
modelDisplay: formatModelDisplay(account.model, account.label || agentId),
|
||||
mainSessionKey: buildMainSessionKey(agentId, DEFAULT_MAIN_SESSION_SUFFIX),
|
||||
vendorId: account.vendorId,
|
||||
source: 'provider-account',
|
||||
});
|
||||
}
|
||||
|
||||
return summaries;
|
||||
}
|
||||
|
||||
export async function handleModelRoutes(
|
||||
request: NormalizedHostApiRequest,
|
||||
ctx: HostApiContext,
|
||||
) {
|
||||
const { pathname, method } = request;
|
||||
if (pathname !== '/api/models' || method !== 'GET') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const accounts = ctx.providerApiService
|
||||
.getAccounts()
|
||||
.filter((account) => account.enabled !== false);
|
||||
const defaultAccountId = ctx.providerApiService.getDefault().accountId;
|
||||
const defaultAccount = accounts.find((account) => account.id === defaultAccountId) ?? accounts[0] ?? null;
|
||||
|
||||
const models = [
|
||||
buildMainModel(defaultAccount),
|
||||
...buildProviderBackedModels(accounts),
|
||||
];
|
||||
|
||||
return ok({
|
||||
success: true,
|
||||
models,
|
||||
agents: models,
|
||||
defaultAgentId: DEFAULT_AGENT_ID,
|
||||
defaultProviderAccountId: defaultAccount?.id ?? null,
|
||||
defaultModelRef: defaultAccount?.model ?? null,
|
||||
mainSessionSuffix: DEFAULT_MAIN_SESSION_SUFFIX,
|
||||
configuredChannelTypes: [],
|
||||
channelOwners: {},
|
||||
channelAccountOwners: {},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user