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
32 lines • 1.51 kB
TypeScript
import { Express } from 'express';
import { ChatHandler } from '../models/ChatModels';
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
import { ToolCallService } from './ToolCallService';
/**
* Class representing the API facade for handling chat requests and responses.
* This class sets up the necessary routes and middleware for the Express application
* to handle chat requests from Ollama clients and stream responses back to them.
*/
export declare class OllamaApiFacade {
private app;
private baseChatModel;
private toolService;
MODEL_NAME: string;
DEFAULT_PORT: number;
DEFAULT_HOST: string;
private apiRoutes;
constructor(app: Express, baseChatModel: BaseChatModel, modelName: string, toolService: ToolCallService);
private applyMiddleware;
/**
* Sets up the POST /api/chat route to handle chat requests from Ollama clients.
* @param {ChatHandler} chatHandler - The handler function to process chat requests.
*/
postApiChat(chatHandler: ChatHandler): void;
/**
* Starts the Express server and listens on the default Ollama API port 11434.
* @param {Function} [callback] - Optional callback function to execute once the server is running.
* @returns {Server} - The HTTP server instance.
*/
listen(callback?: (address: string) => void): import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
}
//# sourceMappingURL=OllamaApiFacade.d.ts.map