78 lines
2.1 KiB
Objective-C
78 lines
2.1 KiB
Objective-C
//
|
||
// KBAiChatMessage.h
|
||
// keyBoard
|
||
//
|
||
// Created by Kiro on 2026/1/23.
|
||
//
|
||
|
||
#import <Foundation/Foundation.h>
|
||
|
||
NS_ASSUME_NONNULL_BEGIN
|
||
|
||
/// 消息类型
|
||
typedef NS_ENUM(NSInteger, KBAiChatMessageType) {
|
||
KBAiChatMessageTypeUser, // 用户消息
|
||
KBAiChatMessageTypeAssistant, // AI 回复
|
||
KBAiChatMessageTypeTime // 时间戳
|
||
};
|
||
|
||
/// AI 聊天消息模型
|
||
@interface KBAiChatMessage : NSObject
|
||
|
||
/// 消息类型
|
||
@property (nonatomic, assign) KBAiChatMessageType type;
|
||
|
||
/// 文本内容
|
||
@property (nonatomic, copy) NSString *text;
|
||
|
||
/// 消息时间戳
|
||
@property (nonatomic, strong) NSDate *timestamp;
|
||
|
||
/// 语音时长(秒)- 仅 AI 消息使用
|
||
@property (nonatomic, assign) NSTimeInterval audioDuration;
|
||
|
||
/// 语音数据 - 仅 AI 消息使用
|
||
@property (nonatomic, strong, nullable) NSData *audioData;
|
||
|
||
/// 音频 ID - 用于异步加载音频
|
||
@property (nonatomic, copy, nullable) NSString *audioId;
|
||
|
||
/// 是否完成(用于打字机效果)
|
||
@property (nonatomic, assign) BOOL isComplete;
|
||
|
||
/// 是否需要打字机效果(只有当前正在输入的消息才需要)
|
||
@property (nonatomic, assign) BOOL needsTypewriterEffect;
|
||
|
||
/// 是否处于加载状态(用户消息)
|
||
@property (nonatomic, assign) BOOL isLoading;
|
||
|
||
#pragma mark - 便捷构造方法
|
||
|
||
/// 创建加载中的用户消息
|
||
+ (instancetype)loadingUserMessage;
|
||
|
||
/// 创建用户消息
|
||
+ (instancetype)userMessageWithText:(NSString *)text;
|
||
|
||
/// 创建 AI 消息(带语音)
|
||
+ (instancetype)assistantMessageWithText:(NSString *)text
|
||
audioDuration:(NSTimeInterval)duration
|
||
audioData:(nullable NSData *)audioData;
|
||
|
||
/// 创建 AI 消息(带 audioId,异步加载音频)
|
||
+ (instancetype)assistantMessageWithText:(NSString *)text
|
||
audioId:(nullable NSString *)audioId;
|
||
|
||
/// 创建 AI 消息(仅文本,无音频)
|
||
+ (instancetype)assistantMessageWithText:(NSString *)text;
|
||
|
||
/// 创建加载中的 AI 消息
|
||
+ (instancetype)loadingAssistantMessage;
|
||
|
||
/// 创建时间戳消息
|
||
+ (instancetype)timeMessageWithTimestamp:(NSDate *)timestamp;
|
||
|
||
@end
|
||
|
||
NS_ASSUME_NONNULL_END
|