// // KBAiChatView.h // keyBoard // // Created by Mac on 2026/1/15. // #import NS_ASSUME_NONNULL_BEGIN /// 消息类型 typedef NS_ENUM(NSInteger, KBAiChatMessageType) { KBAiChatMessageTypeUser, // 用户消息 KBAiChatMessageTypeAssistant // AI 回复 }; /// 聊天消息模型 @interface KBAiChatMessage : NSObject @property(nonatomic, assign) KBAiChatMessageType type; @property(nonatomic, copy) NSString *text; @property(nonatomic, assign) BOOL isComplete; // 是否完成(用于打字机效果) + (instancetype)userMessageWithText:(NSString *)text; + (instancetype)assistantMessageWithText:(NSString *)text; @end /// 聊天视图 /// 显示用户消息和 AI 回复的气泡列表 @interface KBAiChatView : UIView /// 添加用户消息 /// @param text 消息文本 - (void)addUserMessage:(NSString *)text; /// 添加 AI 消息 /// @param text 消息文本 - (void)addAssistantMessage:(NSString *)text; /// 更新最后一条 AI 消息(用于打字机效果) /// @param text 当前可见文本 - (void)updateLastAssistantMessage:(NSString *)text; /// 标记最后一条 AI 消息完成 - (void)markLastAssistantMessageComplete; /// 清空所有消息 - (void)clearMessages; /// 滚动到底部 - (void)scrollToBottom; @end NS_ASSUME_NONNULL_END