UNPKG

@mastra/core

Version:
39 lines (38 loc) 1.57 kB
import { i as MastraError } from "./error-MjDSls8S.js"; //#region src/llm/model/capability-file.ts function getCapabilityFileName(provider) { return `${encodeURIComponent(provider)}.json`; } //#endregion //#region src/llm/model/gateways/gateway-helpers.ts function getGatewayId(gateway) { return gateway.getId?.() ?? gateway.id; } function shouldEnableGateway(gateway) { return gateway.shouldEnable?.() ?? true; } /** * Find the gateway that handles a specific model ID based on gateway ID * Gateway ID is used as the prefix (e.g., "netlify" for netlify gateway) * Exception: models.dev is a provider registry and doesn't use a prefix */ function findGatewayForModel(gatewayId, gateways) { const prefixedGateway = gateways.find((g) => { const id = getGatewayId(g); return id !== "models.dev" && (id === gatewayId || gatewayId.startsWith(`${id}/`)); }); if (prefixedGateway) return prefixedGateway; const claimingGateway = gateways.find((g) => getGatewayId(g) !== "models.dev" && g.handlesModel?.(gatewayId) === true); if (claimingGateway) return claimingGateway; const modelsDevGateway = gateways.find((g) => getGatewayId(g) === "models.dev"); if (modelsDevGateway) return modelsDevGateway; throw new MastraError({ id: "MODEL_ROUTER_NO_GATEWAY_FOUND", category: "USER", domain: "MODEL_ROUTER", text: `No Mastra model router gateway found for model id ${gatewayId}` }); } //#endregion export { getCapabilityFileName as i, getGatewayId as n, shouldEnableGateway as r, findGatewayForModel as t }; //# sourceMappingURL=gateway-helpers-DusR3xFY.js.map