assistant-robot
Version:
An assistant widget, have a 3D robot which can interact with user, have a simple LLM which can chat with user.
38 lines (37 loc) • 1.33 kB
TypeScript
import type { QuestionAndAnswer } from "@tensorflow-models/qna";
import "@tensorflow/tfjs-core";
import "@tensorflow/tfjs-backend-cpu";
import "@tensorflow/tfjs-backend-webgl";
import { ELanguageModelStatus } from "./constants";
import type { TCallback, ILanguageModelOptions } from "./type";
/**
* the abstract class to use a language model.
* The language model manager should to extend this class to used in the assistant.
*/
export declare abstract class LanguageModel {
status: ELanguageModelStatus;
onLoadList: TCallback[];
loaded(): void;
onLoad(fn: TCallback): void;
removeLoadCb(fn: TCallback): void;
abstract findAnswers(question: string): Promise<string>;
constructor();
}
/**
* The default language model implementation to used in assistant robot.
* It used mobile bert(https://openreview.net/forum?id=SJxjVaNKwB).
* It is faster and smaller, but it's not very good.
*/
export declare class MobileBertModel extends LanguageModel {
passage: string;
modelUrl: string;
model: QuestionAndAnswer | undefined;
constructor({ passage, modelUrl }: ILanguageModelOptions);
init(): Promise<void>;
/**
* ask model question
* @param question question to ask
* @returns answer of the question
*/
findAnswers(question: string): Promise<string>;
}