// // AiVM.h // keyBoard // // Created by Mac on 2026/1/22. // #import #import "KBPersonaPageModel.h" #import "KBChatHistoryPageModel.h" NS_ASSUME_NONNULL_BEGIN @interface KBAiSyncData : NSObject @property(nonatomic, copy, nullable) NSString *aiResponse; @property(nonatomic, copy, nullable) NSString *audioBase64; @property(nonatomic, strong, nullable) NSData *audioData; @end @interface KBAiSyncResponse : NSObject @property(nonatomic, assign) NSInteger code; @property(nonatomic, strong, nullable) KBAiSyncData *data; @end typedef void (^AiVMSyncCompletion)(KBAiSyncResponse *_Nullable response, NSError *_Nullable error); @interface KBAiMessageData : NSObject @property(nonatomic, copy, nullable) NSString *content; @property(nonatomic, copy, nullable) NSString *text; @property(nonatomic, copy, nullable) NSString *message; @property(nonatomic, copy, nullable) NSString *aiResponse; @property(nonatomic, copy, nullable) NSString *audioId; @property(nonatomic, assign) NSInteger llmDuration; @end @interface KBAiMessageResponse : NSObject @property(nonatomic, assign) NSInteger code; @property(nonatomic, strong, nullable) KBAiMessageData *data; @property(nonatomic, copy, nullable) NSString *message; @end typedef void (^AiVMMessageCompletion)(KBAiMessageResponse *_Nullable response, NSError *_Nullable error); typedef void (^AiVMAudioURLCompletion)(NSString *_Nullable audioURL, NSError *_Nullable error); typedef void (^AiVMUploadAudioCompletion)(NSString *_Nullable fileURL, NSError *_Nullable error); @interface KBAiSpeechTranscribeData : NSObject @property(nonatomic, copy, nullable) NSString *transcript; @property(nonatomic, assign) double confidence; @property(nonatomic, assign) double duration; @property(nonatomic, copy, nullable) NSString *detectedLanguage; @end @interface KBAiSpeechTranscribeResponse : NSObject @property(nonatomic, assign) NSInteger code; @property(nonatomic, strong, nullable) KBAiSpeechTranscribeData *data; @property(nonatomic, copy, nullable) NSString *message; @end typedef void (^AiVMSpeechTranscribeCompletion)(KBAiSpeechTranscribeResponse *_Nullable response, NSError *_Nullable error); @interface AiVM : NSObject - (void)syncChatWithTranscript:(NSString *)transcript completion:(AiVMSyncCompletion)completion; - (void)requestChatMessageWithContent:(NSString *)content companionId:(NSInteger)companionId completion:(AiVMMessageCompletion)completion; /// 根据 audioId 获取音频 URL - (void)requestAudioWithAudioId:(NSString *)audioId completion:(AiVMAudioURLCompletion)completion; /// 上传语音文件(m4a) - (void)uploadAudioFileAtURL:(NSURL *)fileURL completion:(AiVMUploadAudioCompletion)completion; /// 语音转文字(multipart/form-data) - (void)transcribeAudioFileAtURL:(NSURL *)fileURL completion:(AiVMSpeechTranscribeCompletion)completion; #pragma mark - 人设相关接口 /// 分页查询人设列表 /// @param pageNum 页码(从 1 开始) /// @param pageSize 每页大小 /// @param completion 完成回调 - (void)fetchPersonasWithPageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize completion:(void(^)(KBPersonaPageModel * _Nullable pageModel, NSError * _Nullable error))completion; /// 分页查询聊天记录 /// @param companionId AI 陪聊角色 ID /// @param pageNum 页码(从 1 开始) /// @param pageSize 每页大小 /// @param completion 完成回调 - (void)fetchChatHistoryWithCompanionId:(NSInteger)companionId pageNum:(NSInteger)pageNum pageSize:(NSInteger)pageSize completion:(void(^)(KBChatHistoryPageModel * _Nullable pageModel, NSError * _Nullable error))completion; @end NS_ASSUME_NONNULL_END