@inworld/web-core
Version:
56 lines (55 loc) • 2.95 kB
TypeScript
import { InworldPacket as ProtoPacket } from '../../proto/ai/inworld/packets/packets.pb.js';
import { AudioSessionStartPacketParams, CancelResponsesProps, PerceivedLatencyReportProps, SendPacketParams, TriggerParameter, TtsPlaybackAction } from '../common/data_structures/index.js';
import { ConvesationInterface } from '../common/data_structures/extension.js';
import { Character } from '../entities/character.entity.js';
import { InworldPacket } from '../entities/packets/inworld_packet.entity.js';
import { ConnectionService } from './connection.service.js';
export interface PacketQueueItem<InworldPacketT extends InworldPacket = InworldPacket> {
getPacket: () => ProtoPacket;
afterWriting: (packet: InworldPacketT) => void;
}
export declare class ConversationService<InworldPacketT extends InworldPacket = InworldPacket> implements ConvesationInterface<InworldPacketT> {
private connection;
private conversationId;
private participants;
private addCharacters?;
private startRecording?;
private stopRecording?;
private packetQueue;
private ttsPlaybackAction;
constructor(connection: ConnectionService<InworldPacketT>, { participants, conversationId, addCharacters, startRecording, stopRecording, }: {
participants: string[];
conversationId?: string;
addCharacters: (names: string[]) => Promise<void>;
startRecording?: () => Promise<void>;
stopRecording?: () => void;
});
getConversationId(): string;
getParticipants(): string[];
getCharacters(): Character[];
getHistory(): import("../index.js").HistoryItem[];
getTranscript(): string;
changeParticipants(participants: string[]): void;
updateParticipants(participants: string[]): Promise<ConvesationInterface<InworldPacketT>>;
sendText(text: string): Promise<InworldPacketT>;
sendAudio(chunk: string): Promise<InworldPacketT>;
sendTrigger(name: string, parameters?: {
parameters?: TriggerParameter[];
character?: Character;
}): Promise<InworldPacketT>;
sendAudioSessionStart(params?: AudioSessionStartPacketParams, force?: boolean): Promise<InworldPacketT>;
sendAudioSessionEnd(force?: boolean): Promise<InworldPacketT>;
sendCancelResponse(cancelResponses?: CancelResponsesProps): Promise<InworldPacketT>;
sendTTSPlaybackMute(isMuted: boolean): Promise<InworldPacketT>;
sendNarratedAction(text: string): Promise<InworldPacketT>;
sendCustomPacket(getPacket: (params: SendPacketParams) => ProtoPacket): Promise<InworldPacketT>;
sendPerceivedLatenctReport(props: PerceivedLatencyReportProps): Promise<InworldPacketT>;
private ensureConversation;
private beforeAudioSessionStart;
private beforeAudioSessionEnd;
setTtsPlaybackAction(action: TtsPlaybackAction): void;
getTtsPlaybackAction(): TtsPlaybackAction;
private resolveInterval;
private releaseQueue;
private getCharacterParticipants;
}