处理语音

This commit is contained in:
2026-01-29 20:56:24 +08:00
parent 23c0d14128
commit 36135313d8
8 changed files with 236 additions and 9 deletions

View File

@@ -503,6 +503,10 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
}
[self ensureOpeningMessageAtTop];
// loading
[self removeLoadingAssistantMessage];
KBAiChatMessage *message = [KBAiChatMessage assistantMessageWithText:text
audioId:audioId];
message.needsTypewriterEffect = YES;
@@ -510,6 +514,33 @@ static NSString * const KBChatSessionDidResetNotification = @"KBChatSessionDidRe
[self.chatView addMessage:message autoScroll:YES];
}
/// loading AI
- (void)appendLoadingAssistantMessage {
if (!self.messages) {
self.messages = [NSMutableArray array];
}
[self ensureOpeningMessageAtTop];
KBAiChatMessage *message = [KBAiChatMessage loadingAssistantMessage];
[self.messages addObject:message];
[self.chatView addMessage:message autoScroll:YES];
}
/// loading AI
- (void)removeLoadingAssistantMessage {
//
for (NSInteger i = self.messages.count - 1; i >= 0; i--) {
KBAiChatMessage *message = self.messages[i];
if (message.type == KBAiChatMessageTypeAssistant && message.isLoading) {
[self.messages removeObjectAtIndex:i];
break;
}
}
// chatView
[self.chatView removeLoadingAssistantMessage];
}
- (void)updateChatViewBottomInset:(CGFloat)bottomInset {
[self.chatView updateContentBottomInset:bottomInset];
}