mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 09:02:08 +00:00
Initial monorepo setup with npm workspaces and dual TypeScript configuration
- Set up npm workspaces for three packages: pi-tui, pi-agent, and pi (pods) - Implemented dual TypeScript configuration: - Root tsconfig.json with path mappings for development and type checking - Package-specific tsconfig.build.json for clean production builds - Configured lockstep versioning with sync script for inter-package dependencies - Added comprehensive documentation for development and publishing workflows - All packages at version 0.5.0 ready for npm publishing
This commit is contained in:
commit
a74c5da112
63 changed files with 14558 additions and 0 deletions
111
packages/pods/src/model-configs.ts
Normal file
111
packages/pods/src/model-configs.ts
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
import { readFileSync } from "fs";
|
||||
import { dirname, join } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import type { GPU } from "./types.js";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
interface ModelConfig {
|
||||
gpuCount: number;
|
||||
gpuTypes?: string[];
|
||||
args: string[];
|
||||
env?: Record<string, string>;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
interface ModelInfo {
|
||||
name: string;
|
||||
configs: ModelConfig[];
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
interface ModelsData {
|
||||
models: Record<string, ModelInfo>;
|
||||
}
|
||||
|
||||
// Load models configuration - resolve relative to this file
|
||||
const modelsJsonPath = join(__dirname, "models.json");
|
||||
const modelsData: ModelsData = JSON.parse(readFileSync(modelsJsonPath, "utf-8"));
|
||||
|
||||
/**
|
||||
* Get the best configuration for a model based on available GPUs
|
||||
*/
|
||||
export const getModelConfig = (
|
||||
modelId: string,
|
||||
gpus: GPU[],
|
||||
requestedGpuCount: number,
|
||||
): { args: string[]; env?: Record<string, string>; notes?: string } | null => {
|
||||
const modelInfo = modelsData.models[modelId];
|
||||
if (!modelInfo) {
|
||||
// Unknown model, no default config
|
||||
return null;
|
||||
}
|
||||
|
||||
// Extract GPU type from the first GPU name (e.g., "NVIDIA H200" -> "H200")
|
||||
const gpuType = gpus[0]?.name?.replace("NVIDIA", "")?.trim()?.split(" ")[0] || "";
|
||||
|
||||
// Find best matching config
|
||||
let bestConfig: ModelConfig | null = null;
|
||||
|
||||
for (const config of modelInfo.configs) {
|
||||
// Check GPU count
|
||||
if (config.gpuCount !== requestedGpuCount) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check GPU type if specified
|
||||
if (config.gpuTypes && config.gpuTypes.length > 0) {
|
||||
const typeMatches = config.gpuTypes.some((type) => gpuType.includes(type) || type.includes(gpuType));
|
||||
if (!typeMatches) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// This config matches
|
||||
bestConfig = config;
|
||||
break;
|
||||
}
|
||||
|
||||
// If no exact match, try to find a config with just the right GPU count
|
||||
if (!bestConfig) {
|
||||
for (const config of modelInfo.configs) {
|
||||
if (config.gpuCount === requestedGpuCount) {
|
||||
bestConfig = config;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bestConfig) {
|
||||
// No suitable config found
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
args: [...bestConfig.args],
|
||||
env: bestConfig.env ? { ...bestConfig.env } : undefined,
|
||||
notes: bestConfig.notes || modelInfo.notes,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a model is known
|
||||
*/
|
||||
export const isKnownModel = (modelId: string): boolean => {
|
||||
return modelId in modelsData.models;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get all known models
|
||||
*/
|
||||
export const getKnownModels = (): string[] => {
|
||||
return Object.keys(modelsData.models);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get model display name
|
||||
*/
|
||||
export const getModelName = (modelId: string): string => {
|
||||
return modelsData.models[modelId]?.name || modelId;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue