import { Observable } from "rxjs"; import Parse from "parse"; import { NavController } from "@ionic/angular"; import { FmodeTTS } from "../../voice/tts"; import { NovaCloudService } from "../../../nova-cloud"; import { NovaUploadService } from "../../../storage/service-upload/nova-upload.service"; import { ElementRef } from "@angular/core"; export interface FmodeChatMessageVoice { id: string; duration?: number; ssml?: string; voiceUrl?: string; } export interface FmodeChatEventMap { onComplete?(FmodeChatMessage: any): void; onSSMLComplete?(FmodeChatMessageVoice: any): void; } export interface FmodeChatVoiceConfig { voice: string; autoTalk: boolean; welcome: { enabled: true; }; } export declare function getMessageContentText(content: any | string | Array): string; export declare function getMessageImageUrl(content: any | string | Array): any; export interface ChatImageContentItem { type: string; text?: string; image_url?: { url: string; }; } export interface FmodeChatMessage { role: string; content: string | Array; json?: any; hidden?: boolean; createdAt?: Date; complete?: boolean; voice?: FmodeChatMessageVoice; /**AI回复消息字段 */ cid?: string; } /** * FmodeChat 聊天对话类 * @public */ export declare class FmodeChat { title: string; sessionId: string; ChatSession: any; chatSession: Parse.Object; role: any; messageList: FmodeChatMessage[]; latestAIResponse: string | undefined; chatServ: any; userInput: string; userImage: string; isDirect: boolean; /** * 函数生命周期 */ onChatSaved: (chat: FmodeChat) => void; onMessage: (chat: FmodeChat, message: FmodeChatMessage) => void; onUserSend: (chat: FmodeChat, message: FmodeChatMessage) => boolean | Promise; onClose: (chat: FmodeChat) => boolean | Promise; hideShare: boolean; hideModalSelect: boolean; hideInputPreview: boolean; /** * 虚拟形象展示状态 */ isAvatarShow: boolean; avatarMode: string; avatarConfig: any | undefined; showAvatar(): void; /** * 预置提示词弹窗是否展示 */ isPromptModalOpen: boolean; isPromptMessageAreaShow: boolean; promptList: any; /** * 输入按钮区域 */ focusUserInput: Function; navCtrl: NavController; leftButtons: Array; /** * 是否开启语音消息模式(单次) */ isVoiceInputMode: boolean; isTexting: boolean; /** * 是否开启实时对话模式(实时) * @desc * 开启ssml system提示词 * 开启回答文本除xml显示模式 */ voiceConfig: FmodeChatVoiceConfig | undefined; isTalkMode: boolean; SSMLRoleVoice: string; /** * 滚动至消息区域底部方法 * @desc 通过chat-panel等聊天面板,赋值该方法 */ scrollComp: ElementRef; scrollToBottom(comp?: ElementRef): void; /** * 依赖服务 */ ncloud: NovaCloudService; uploadServ: NovaUploadService; constructor(sessionId: string, role?: Parse.Object, chatSession?: Parse.Object, chatServ?: any, navCtrl?: NavController, ncloud?: NovaCloudService, uploadServ?: NovaUploadService); /** * 会话Avatar控制 */ playAnimation: (animName: string) => void; welcome: () => Promise; getTimeOfDay(): "早上" | "中午" | "下午" | "晚上"; self: { Person?: Parse.Object | undefined; Profile?: Parse.Object | undefined; }; loadSelf(className: any, userKey: any): Promise; /** * 对话模型提示词 */ loadTalkSystemPrompt(role: Parse.Object): Promise; /** * 角色提示词 * @returns */ loadRolePrompt(): void; /** * 发送消息 * @param message * @param imageUrl */ sendMessage(message?: string, imageUrl?: string, onComplete?: Function, eventMap?: FmodeChatEventMap, voice?: FmodeChatMessageVoice): Promise; getVoiceByContentText(content: string | ChatImageContentItem[], eventMap?: FmodeChatEventMap, promptEnabled?: boolean): Promise; getContentText(content: string | ChatImageContentItem[]): string; /** * TTS - 语音合成 * */ initTTS(): Promise; voiceMap: any; VoiceTTSMap: { [key: string]: FmodeTTS; }; stopPlayingVoice(): void; playChatVoice(voice: Parse.Object, eventMap?: any): Promise; /** * 保存单次会话 */ saveChatSession(): Promise; getInviteUrl(url: any): string; genTitle(): string; fixMessageList(messages: FmodeChatMessage[]): { role: string; content: string | ChatImageContentItem[]; }[]; nowStr(): string; } /** * FmodeChatCompletion 文本补全类 * @public */ export declare class FmodeChatCompletion { indexOfList: number; model: string; messages: FmodeChatMessage[]; content: string; contentBuffer: string[]; contentPusher: any; isCompleted: boolean; constructor(messages: FmodeChatMessage[], options?: { model?: string; }); /** * @param options * @param options.isDirect 是否不等待逐字获取,直接完成内容推送 * @param options.intTime 是否不等待逐字获取,直接完成内容推送 * @returns */ sendCompletion(options?: { isDirect?: boolean; intTime?: number; onComplete?: Function; }): Observable; }