123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 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<ChatImageContentItem>): string;
- export declare function getMessageImageUrl(content: any | string | Array<ChatImageContentItem>): any;
- export interface ChatImageContentItem {
- type: string;
- text?: string;
- image_url?: {
- url: string;
- };
- }
- export interface FmodeChatMessage {
- role: string;
- content: string | Array<ChatImageContentItem>;
- 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<boolean>;
- onClose: (chat: FmodeChat) => boolean | Promise<boolean>;
- 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<any>;
- /**
- * 是否开启语音消息模式(单次)
- */
- 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<void>;
- getTimeOfDay(): "早上" | "中午" | "下午" | "晚上";
- self: {
- Person?: Parse.Object | undefined;
- Profile?: Parse.Object | undefined;
- };
- loadSelf(className: any, userKey: any): Promise<any>;
- /**
- * 对话模型提示词
- */
- loadTalkSystemPrompt(role: Parse.Object): Promise<void>;
- /**
- * 角色提示词
- * @returns
- */
- loadRolePrompt(): void;
- /**
- * 发送消息
- * @param message
- * @param imageUrl
- */
- sendMessage(message?: string, imageUrl?: string, onComplete?: Function, eventMap?: FmodeChatEventMap, voice?: FmodeChatMessageVoice): Promise<void>;
- getVoiceByContentText(content: string | ChatImageContentItem[], eventMap?: FmodeChatEventMap, promptEnabled?: boolean): Promise<FmodeChatMessageVoice>;
- getContentText(content: string | ChatImageContentItem[]): string;
- /**
- * TTS - 语音合成
- *
- */
- initTTS(): Promise<FmodeTTS | null>;
- voiceMap: any;
- VoiceTTSMap: {
- [key: string]: FmodeTTS;
- };
- stopPlayingVoice(): void;
- playChatVoice(voice: Parse.Object, eventMap?: any): Promise<FmodeTTS | null>;
- /**
- * 保存单次会话
- */
- saveChatSession(): Promise<void>;
- 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<FmodeChatMessage>;
- }
|