{"version":3,"file":"model-configs.d.ts","sourceRoot":"","sources":["../src/model-configs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AA2BtC;;GAEG;AACH,eAAO,MAAM,cAAc;;;;QAwD1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,8BAExB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,gBAE1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,6BAExB,CAAC","sourcesContent":["import { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { GPU } from \"./types.js\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\ninterface ModelConfig {\n\tgpuCount: number;\n\tgpuTypes?: string[];\n\targs: string[];\n\tenv?: Record<string, string>;\n\tnotes?: string;\n}\n\ninterface ModelInfo {\n\tname: string;\n\tconfigs: ModelConfig[];\n\tnotes?: string;\n}\n\ninterface ModelsData {\n\tmodels: Record<string, ModelInfo>;\n}\n\n// Load models configuration - resolve relative to this file\nconst modelsJsonPath = join(__dirname, \"models.json\");\nconst modelsData: ModelsData = JSON.parse(readFileSync(modelsJsonPath, \"utf-8\"));\n\n/**\n * Get the best configuration for a model based on available GPUs\n */\nexport const getModelConfig = (\n\tmodelId: string,\n\tgpus: GPU[],\n\trequestedGpuCount: number,\n): { args: string[]; env?: Record<string, string>; notes?: string } | null => {\n\tconst modelInfo = modelsData.models[modelId];\n\tif (!modelInfo) {\n\t\t// Unknown model, no default config\n\t\treturn null;\n\t}\n\n\t// Extract GPU type from the first GPU name (e.g., \"NVIDIA H200\" -> \"H200\")\n\tconst gpuType = gpus[0]?.name?.replace(\"NVIDIA\", \"\")?.trim()?.split(\" \")[0] || \"\";\n\n\t// Find best matching config\n\tlet bestConfig: ModelConfig | null = null;\n\n\tfor (const config of modelInfo.configs) {\n\t\t// Check GPU count\n\t\tif (config.gpuCount !== requestedGpuCount) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Check GPU type if specified\n\t\tif (config.gpuTypes && config.gpuTypes.length > 0) {\n\t\t\tconst typeMatches = config.gpuTypes.some((type) => gpuType.includes(type) || type.includes(gpuType));\n\t\t\tif (!typeMatches) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\t// This config matches\n\t\tbestConfig = config;\n\t\tbreak;\n\t}\n\n\t// If no exact match, try to find a config with just the right GPU count\n\tif (!bestConfig) {\n\t\tfor (const config of modelInfo.configs) {\n\t\t\tif (config.gpuCount === requestedGpuCount) {\n\t\t\t\tbestConfig = config;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!bestConfig) {\n\t\t// No suitable config found\n\t\treturn null;\n\t}\n\n\treturn {\n\t\targs: [...bestConfig.args],\n\t\tenv: bestConfig.env ? { ...bestConfig.env } : undefined,\n\t\tnotes: bestConfig.notes || modelInfo.notes,\n\t};\n};\n\n/**\n * Check if a model is known\n */\nexport const isKnownModel = (modelId: string): boolean => {\n\treturn modelId in modelsData.models;\n};\n\n/**\n * Get all known models\n */\nexport const getKnownModels = (): string[] => {\n\treturn Object.keys(modelsData.models);\n};\n\n/**\n * Get model display name\n */\nexport const getModelName = (modelId: string): string => {\n\treturn modelsData.models[modelId]?.name || modelId;\n};\n"]}