UNPKG

wdpapi

Version:

51WORLD WdpApi is a set of programming interfaces developed by JavaScript that is responsible for negotiating between web pages and cloud rendering platforms. Supported by 51Cloud rendering platform, it enables the users to create any HTML5 UI element on

121 lines (120 loc) 2.86 kB
import { Basic } from './common/basic'; import { ResultType } from './common/data-type'; type TonOpenAndClose = () => void; type TonMessage = (event: EventSourceEventMap['message']) => void; type TonError = (event: EventSourceEventMap['error']) => void; interface IStart { onOpen?: TonOpenAndClose; onMessage?: TonMessage; onError?: TonError; onClose?: TonOpenAndClose; } interface ITalk { query: string; inputs?: { [key: string]: string | number | boolean; }; conversation_id?: string; } /** * @public * @class AIController * @extends Basic */ declare class AIController extends Basic { private base; private apiQueue; private isExecuting; private eventSource; private onOpen; private onMessage; private onError; private onClose; /** * @constructor * @param {any} obj */ constructor(obj: any); /** * @public * @function SetBase * @param {string} base * @returns {void} */ SetBase(base: string): void; /** * @public * @function SetAgentHost * @param {string} host * @returns {void} */ SetAgentHost(host: string): void; /** * @public * @async * @function Start * @param {IStart} opt * @param {string} path (optional) default is /event * @returns {Promise<ResultType>} */ Start(opt: IStart, path?: string): Promise<ResultType>; /** * @public * @async * @function Stop * @returns {Promise<ResultType>} */ Stop(): Promise<ResultType>; /** * @public * @async * @function Talk * @param {{query: string, inputs: {[key: string]: string | number | boolean}}} opt * @param {string} path (optional) default is /chat * @returns {Promise<ResultType>} */ Talk(opt: ITalk, path?: string): Promise<ResultType>; /** * @public * @async * @function StopChat * @param {string} task_id * @param {string} path (optional) default is /chat * @returns {Promise<ResultType>} */ StopChat(task_id: string, session_id: string, path?: string): Promise<ResultType>; /** * @private * @async * @function runApi * @returns {void} */ private runApi; /** * @private * @function onOpenAction * @returns {void} */ private onOpenAction; /** * @private * @function onCloseAction * @returns {void} */ private onCloseAction; /** * @private * @function onMessageAction * @param {EventSourceEventMap['message']} event * @returns {void} */ private onMessageAction; /** * @private * @function onErrorAction * @param {EventSourceEventMap['error']} event * @returns {void} */ private onErrorAction; } export default AIController;