Makelore 2.0 initial clean snapshot
This commit is contained in:
33
shared/user-model-config.ts
Normal file
33
shared/user-model-config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export const NIANCODE_USER_MODEL_ACCOUNT_ID = 'niancode-user-models';
|
||||
export const NIANCODE_USER_MODEL_ACCOUNT_LABEL = 'Makelore Models';
|
||||
|
||||
const WORKS_SQUARE_MODEL_ROUTING_PREFIXES_TO_STRIP = new Set([
|
||||
'deepseek',
|
||||
]);
|
||||
|
||||
export interface NianCodeUserModelAccountLike {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export function normalizeImportedUserModelId(rawModel: string): string {
|
||||
const trimmed = rawModel.trim();
|
||||
const slashIndex = trimmed.indexOf('/');
|
||||
if (slashIndex <= 0 || slashIndex >= trimmed.length - 1) {
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
const prefix = trimmed.slice(0, slashIndex).toLowerCase();
|
||||
const modelId = trimmed.slice(slashIndex + 1).trim();
|
||||
return WORKS_SQUARE_MODEL_ROUTING_PREFIXES_TO_STRIP.has(prefix) && modelId
|
||||
? modelId
|
||||
: trimmed;
|
||||
}
|
||||
|
||||
export function selectUserModelRuntimeAccounts<T extends NianCodeUserModelAccountLike>(
|
||||
accounts: T[],
|
||||
): T[] {
|
||||
const importedUserModelAccount = accounts.find((account) => (
|
||||
account.id === NIANCODE_USER_MODEL_ACCOUNT_ID
|
||||
));
|
||||
return importedUserModelAccount ? [importedUserModelAccount] : accounts;
|
||||
}
|
||||
Reference in New Issue
Block a user