Files
keyboard/CustomKeyboard/Model/KBChatMessage.h
2026-01-30 13:17:11 +08:00

50 lines
1.5 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// KBChatMessage.h
// CustomKeyboard
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface KBChatMessage : NSObject
@property (nonatomic, copy) NSString *text;
@property (nonatomic, assign) BOOL outgoing;
@property (nonatomic, copy, nullable) NSString *audioFilePath;
@property (nonatomic, copy, nullable) NSString *avatarURL;
@property (nonatomic, copy, nullable) NSString *displayName;
@property (nonatomic, strong, nullable) UIImage *avatarImage;
/// 是否处于加载状态
@property (nonatomic, assign) BOOL isLoading;
/// 是否完成(用于打字机效果)
@property (nonatomic, assign) BOOL isComplete;
/// 是否需要打字机效果
@property (nonatomic, assign) BOOL needsTypewriterEffect;
/// 音频 ID用于异步加载音频
@property (nonatomic, copy, nullable) NSString *audioId;
/// 音频数据(缓存)
@property (nonatomic, strong, nullable) NSData *audioData;
/// 音频时长(秒)
@property (nonatomic, assign) NSTimeInterval audioDuration;
+ (instancetype)messageWithText:(NSString *)text
outgoing:(BOOL)outgoing
audioFilePath:(nullable NSString *)audioFilePath;
/// 创建用户消息
+ (instancetype)userMessageWithText:(NSString *)text;
/// 创建 AI 消息(带 audioId
+ (instancetype)assistantMessageWithText:(NSString *)text
audioId:(nullable NSString *)audioId;
/// 创建加载中的 AI 消息
+ (instancetype)loadingAssistantMessage;
@end
NS_ASSUME_NONNULL_END