/** * Author: Srilal S. Siriwardhane * Email: SrilalS@99x.io **/ import { AbstractLLMInferenceEngine } from "./AbstractLLMInferenceEngine.js"; import { AvailableModels } from "../types/AvailableModels.js"; import { ChatMessage } from "../types/ChatMessages.js"; import { TextGenerationOutput, TextGenerationPipeline } from '@huggingface/transformers'; 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 TransformerJSModel = Model | 'llama' | 'llama32' | 'gemma' | 'tinymistral'; /** * TransformerJSInferenceEngine class to handle the LLM Inference using the TransformerJS. * This class extends the LLMInferenceFactory to enforce the methods. */ export declare class TransformerJSInferenceEngine extends AbstractLLMInferenceEngine { private status; private statusEmitter; private localModelsMode; llmModel: TransformerJSModel; engine: TextGenerationPipeline; /** * constructor * @param model - The model to be used for inference. should be one of allowed models. * Allowed Models: 'llama', 'gemma', 'tinyllama' * This list of models will be updated as more models are added in the future releases. * * the `env.remoteHost` and `env.remotePathTemplate` can be used to set the * remote host and the path template. * * the commented out code can be used to set the local model repos. **/ constructor(model: TransformerJSModel); static init(model: TransformerJSModel, localMode?: boolean): Promise; createEngine(): Promise; availableModels: AvailableModels; runChatInference(chat: ChatMessage[]): Promise; /** * processChatOutput * @param chatOutput - The output from the chat inference. * @returns Promise * * This function is used to process the chat output and return the ChatMessage[]. * All the models have different output formats, so this function is used to process the output. * If the variation between the models is too high, then this function will be * Moved to a separate class and will be extended by the main class. * @throws Error - If the chatOutput is not in the expected format. * */ protected processChatOutput(chatOutput: TextGenerationOutput): Promise; runCompletionInference(prompt: string): Promise; progressCallback(progress: any): 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; /** * 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; } export {};