UNPKG

ollama-api-facade-js

Version:

OllamaApiFacadeJS is an open-source library for running an ExpressJS backend as an Ollama API using LangChainJS. It supports local language models services like LmStudio and allows seamless message conversion and streaming between LangChainJS and Ollama c

38 lines 1.95 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createOllamaApiFacade = createOllamaApiFacade; const OllamaApiFacade_1 = require("./core/OllamaApiFacade"); const ToolCallService_1 = require("./core/ToolCallService"); /** * Creates an instance of OllamaApiFacade. * This function sets up the necessary routes and middleware for the Express application * to handle chat requests from Ollama clients and stream responses back to them. * * @param {Express} app - The Express application instance. * @param {BaseChatModel} baseChatModel - The base chat model to handle chat messages. * @param {string} [modelName='nodeapi'] - The name of the chat model. * @returns {OllamaApiFacade} - The created OllamaApiFacade instance. */ function createOllamaApiFacade(app, baseChatModel, modelName = 'nodeapi') { const facade = new OllamaApiFacade_1.OllamaApiFacade(app, baseChatModel, modelName, new ToolCallService_1.ToolCallService(baseChatModel)); return facade; } __exportStar(require("./models/ChatModels"), exports); __exportStar(require("./config/LMStudioConfig"), exports); __exportStar(require("./utils/MessageUtils"), exports); __exportStar(require("./core/ToolCallService"), exports); //# sourceMappingURL=index.js.map