/** * Author: Srilal S. Siriwardhane * Email: SrilalS@99x.io **/ import { LlmInference } from "@mediapipe/tasks-genai"; import { AvailableModels } from "../types/AvailableModels.js"; import { AbstractLLMInferenceEngine } from "./AbstractLLMInferenceEngine.js"; import { ChatMessage } from "../types/ChatMessages.js"; import { Model } from "../types/Model.js"; import { LLMStatus } from "../types/LLMStatus.js"; /** * TransformerJSModel * This type is extended by the `Model` Enum to enforce the model type. */ type MediaPipeModel = Model | 'gemma-cpu' | 'gemma-gpu'; export declare class MediaPipeInferenceEngine extends AbstractLLMInferenceEngine { private status; private statusEmitter; private localMode; llmModel: MediaPipeModel; llmInference: LlmInference; availableModels: AvailableModels; /** * * @param model - The model to be used for the inference. must be of type `MediaPipeModel`. Currently * supported models are `gemma-cpu` and `gemma-gpu`. * @param localMode - The mode to be used for the inference. Default is `false`. set to `true` if you are * running a model hosting server locally. */ constructor(model: MediaPipeModel, localMode?: boolean); /** * Async function to initialize the MediaPipeInferenceEngine. * @param model - The model to be used for the inference. must be of type `MediaPipeModel`. Currently * supported models are `gemma-cpu` and `gemma-gpu`. * @param localMode - The mode to be used for the inference. Default is `false`. set to `true` if you are * running a model hosting server locally. * @param maxTokens - The maximum number of tokens to be used for the inference. Default is `512`. * @param topK - The number of top K tokens to be used for the inference. Default is `1`. * @param temperature - The temperature to be used for the inference. Default is `0.0`. * @param randomSeed - The random seed to be used for the inference. Default is `1`. */ static init(model: MediaPipeModel, localMode?: boolean, maxTokens?: number, topK?: number, temperature?: number, randomSeed?: number): Promise; /** * createEngine - Async function to create the MediaPipeInferenceEngine. * @param maxTokens - The maximum number of tokens to be used for the inference. Default is `512`. * @param topK - The number of top K tokens to be used for the inference. Default is `1`. * @param temperature - The temperature to be used for the inference. Default is `0.0`. * @param randomSeed - The random seed to be used for the inference. Default is `1`. */ createEngine(maxTokens?: number, topK?: number, temperature?: number, randomSeed?: number): Promise; /** * downloadModel - Async function to download the model from the server. */ downloadModel(): Promise; storeFileInIDB(blob: Blob): Promise; restoreFileFromIDB(): Promise; clearIDB(): Promise; runChatInference(chat: ChatMessage[]): Promise; runCompletionInference(prompt: string): Promise; countCharacterUsingRegex(str: string, char: string): number; runJSONInference(prompt: string): Promise; progressCallback(initProgress: any): void; /** * onStatusChange * @param listener - The listener to be used for status change. * * This function is used to listen to the status change of the inference. * */ onStatusChange(listener: (status: LLMStatus) => void): void; /** * getModel * @returns string * * This function is used to get the model name from the available models. * * @throws Error - If the model is not found or not supported. * */ protected getModel(): string; } export {};