import { DemoChatReplyParam, InteractiveConfig } from '../types/common'; import { AuthResponseData, DemoAuthRequest, StreamDemoAvatarServerHelperConfig, STSResponseWithTranscript, STTParam } from '../types/server'; /** * The `StreamDemoAvatarServerHelper` class provides an interface to the Stream Avatar server for demo purpose, * It only use basic authentication * * **Important**: All methods in this class should be called on the server side, since they * require an API key that should not be exposed to clients. */ export declare class StreamDemoAvatarServerHelper { private siteURL; private basicAuthUser; private basicAuthPass; /** * Creates an instance of `StreamAvatarServerHelper`. * * @param {StreamDemoAvatarServerHelper} config - The configuration object for the helper. * @param {string} [config.url] - The base URL for the Stream Avatar server API. * @param {string} config.apikey - The API key needed to authenticate requests. */ constructor(config: StreamDemoAvatarServerHelperConfig); /** * Obtains an authentication token (and optionally a stream token) for a user. * * This is the most important method, as it provides the Bearer token required for * many further actions (such as creating conversations or getting chat replies). * * @async * @function * @param {AuthRequest} request - The request object containing user identification. * @param {string} request.remote_id - A unique identifier for the user on your system. * @param {string} request.character_slug - The slug of character. * @param {string} [request.name] - The user's full name. * @param {string} [request.dob] - The user's date of birth in YYYY-MM-DD format. * @param {string} [request.gender] - The user's gender. * @param {string} [request.nickname] - The user's nickname. * @returns {Promise} A promise that resolves with the authentication data, * including a `token` and a `stream_token`. * @throws {Error} Throws an error if the request fails, if the response is not OK, * or if the server returns a status of 'error'. */ getToken(request: DemoAuthRequest): Promise; /** * Retrieves interactive character configuration data for a given slug. * * @public * @async * @function * @param {string} uid - The unique identifier of the interactive character. * @returns {Promise} A promise resolving with the interactive configuration data. * @throws {Error} Throws an error if the request fails, if the response is not OK, * or if the server returns a status of 'error'. */ getInteractiveCharacterBySlug(slug: string): Promise; /** * Sends a chat message to the server and retrieves the AI-generated reply from the Character. * * You need a valid basic auth user and pass to use this method. * * @async * @function * @param {DemoChatReplyParam} param - The parameters for the chat message. * @param {string} param.character_slug - The slug of character. * @param {string} param.remote_id - The remote_id of user. * @param {string} param.message - The user's message to the Star. * @returns {Promise} A promise that resolves with the Star's reply to the chat message. * @throws {Error} Throws an error if the request fails, if the response is not OK, * or if the server returns a status of 'error'. */ getChatReply(param: DemoChatReplyParam): Promise; /** * Performs Speech-To-Text (STT) on an audio file and returns the transcribed text. * * This method requires a valid Bearer token (from `getToken`) and the user's audio data. * Internally, it uploads the audio file in a multipart/form-data request to the server. * * @async * @function * @param {STTParam} param - The Speech-To-Text parameters. * @param {ArrayBuffer} param.audio_file - The raw audio data as an ArrayBuffer. * @param {string} [param.language] - The language code for transcription. * @returns {Promise} A promise that resolves with the transcribed text. * @throws {Error} Throws an error if the request fails, if the response is not OK, * or if the server returns a status of 'error'. */ stt(param: STTParam): Promise; /** * Performs Speech-To-Speech (STS) on an audio file and returns the streaming audio with transcript. * * This method requires a valid Basic Auth user and pass and the user's audio data. The form need to contain character_slug & remote_id * Internally, it uploads the audio file in a multipart/form-data request to the server. * * @async * @function * @param {FormData} form - The form data containing file. The form need to contain character_slug and bearer_token * @returns {Promise} A promise that resolves with the STSResponseWithTranscript. * @throws {Error} Throws an error if the request fails, if the response is not OK, * or if the server returns a status of 'error'. */ stsWithTransript(form: FormData): Promise; }