r2papi-async
Version:
r2api on top of r2pipe for typescript and js
62 lines (61 loc) • 1.99 kB
TypeScript
import { R2PipeAsync } from "./r2pipe.js";
/**
* Class that interacts with the `r2ai` plugin (requires `rlang-python` and `r2i` r2pm packages to be installed).
* Provides a way to script the interactions with different language models using javascript from inside radare2.
*
* @typedef R2AI
*/
export declare class R2AI {
/**
* Instance variable that informs if the `r2ai` plugin is loaded, must be true in order to use the rest of the methods of this class.
*
* @type {boolean}
*/
available: boolean;
/**
* Name of the model instantiated to be used for the subsequent calls.
*
* @type {string}
*/
model: string;
r2: R2PipeAsync;
constructor(r2: R2PipeAsync, num?: number, model?: string);
checkAvailability(): Promise<boolean>;
/**
* Reset conversation messages
*/
reset(): Promise<void>;
/**
* Set the role (system prompt) message for the language model to obey.
*
* @param {string} text containing the system prompt
* @returns {boolean} true if successful
*/
setRole(msg: string): Promise<boolean>;
/**
* Set the Model name or path to the GGUF file to use.
*
* @param {string} model name or path to GGUF file
* @returns {boolean} true if successful
*/
setModel(modelName: string): Promise<boolean>;
/**
* Get the current selected model name.
*
* @returns {boolean} model name
*/
getModel(): Promise<string>;
/**
* Get a list of suggestions for model names to use.
*
* @returns {string[]} array of strings containing the model names known to work
*/
listModels(): Promise<string[]>;
/**
* Send message to the language model to be appended to the current conversation (see `.reset()`)
*
* @param {string} text sent from the user to the language model
* @returns {string} response from the language model
*/
query(msg: string): Promise<string>;
}