UNPKG

@llumiverse/drivers

Version:

LLM driver implementations. Currently supported are: openai, huggingface, bedrock, replicate.

32 lines 1.3 kB
import { trimModelName } from "./index.js"; import { GeminiModelDefinition } from "./models/gemini.js"; import { ClaudeModelDefinition } from "./models/claude.js"; import { LLamaModelDefinition } from "./models/llama.js"; export function getModelDefinition(model) { const splits = model.split("/"); // Handle both formats: "publishers/anthropic/models/..." and "locations/.../publishers/anthropic/models/..." let publisher; let modelName; const publisherIndex = splits.indexOf("publishers"); if (publisherIndex !== -1 && publisherIndex + 1 < splits.length) { publisher = splits[publisherIndex + 1]; modelName = trimModelName(splits[splits.length - 1]); } else { // Fallback to old logic for backward compatibility publisher = splits[1]; modelName = trimModelName(splits[splits.length - 1]); } if (publisher?.includes("anthropic")) { return new ClaudeModelDefinition(modelName); } else if (publisher?.includes("google")) { return new GeminiModelDefinition(modelName); } else if (publisher?.includes("meta")) { return new LLamaModelDefinition(modelName); } //Fallback, assume it is Gemini. return new GeminiModelDefinition(modelName); } //# sourceMappingURL=models.js.map