UNPKG

@genkit-ai/vertexai

Version:

Genkit AI framework plugin for Google Cloud Vertex AI APIs including Gemini APIs, Imagen, and more.

110 lines 4.29 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var v2_exports = {}; __export(v2_exports, { vertexModelGarden: () => vertexModelGarden, vertexModelGardenPlugin: () => vertexModelGardenPlugin }); module.exports = __toCommonJS(v2_exports); var import_genkit = require("genkit"); var import_plugin = require("genkit/plugin"); var import_common = require("../../common/index.js"); var anthropic = __toESM(require("./anthropic.js")); var llama = __toESM(require("./llama.js")); var mistral = __toESM(require("./mistral.js")); async function initializer(pluginOptions) { const clientOptions = await (0, import_common.getDerivedParams)(pluginOptions); return [ ...anthropic.listKnownModels(clientOptions, pluginOptions), ...mistral.listKnownModels(clientOptions, pluginOptions), ...llama.listKnownModels(clientOptions, pluginOptions) ]; } async function resolver(actionType, actionName, pluginOptions) { const clientOptions = await (0, import_common.getDerivedParams)(pluginOptions); switch (actionType) { case "model": if (anthropic.isAnthropicModelName(actionName)) { return anthropic.defineModel(actionName, clientOptions, pluginOptions); } else if (mistral.isMistralModelName(actionName)) { return mistral.defineModel(actionName, clientOptions, pluginOptions); } else if (llama.isLlamaModelName(actionName)) { return llama.defineModel(actionName, clientOptions, pluginOptions); } break; } return void 0; } async function listActions(options) { try { const clientOptions = await (0, import_common.getDerivedParams)(options); return [ ...anthropic.listActions(clientOptions), ...mistral.listActions(clientOptions), ...llama.listActions(clientOptions) ]; } catch (e) { return []; } } function vertexModelGardenPlugin(options) { let listActionsCache; return (0, import_plugin.genkitPluginV2)({ name: "vertex-model-garden", init: async () => await initializer(options), resolve: async (actionType, actionName) => await resolver(actionType, actionName, options), list: async () => { if (listActionsCache) return listActionsCache; listActionsCache = await listActions(options); return listActionsCache; } }); } const vertexModelGarden = vertexModelGardenPlugin; vertexModelGarden.model = (name, config) => { if (anthropic.isAnthropicModelName(name)) { return anthropic.model(name, config); } if (mistral.isMistralModelName(name)) { return mistral.model(name, config); } if (llama.isLlamaModelName(name)) { return llama.model(name, config); } throw new import_genkit.GenkitError({ status: "INVALID_ARGUMENT", message: `model '${name}' is not a recognized model name` }); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { vertexModelGarden, vertexModelGardenPlugin }); //# sourceMappingURL=index.js.map