This commit is contained in:
2026-01-26 18:51:37 +08:00
parent a22599feda
commit 3a5a6395af
4 changed files with 43 additions and 4 deletions

View File

@@ -248,6 +248,25 @@
[self.voiceToTextManager prepareConnection];
}
- (NSInteger)currentCompanionId {
if (self.personas.count == 0) {
return 0;
}
NSInteger index = self.currentIndex;
if (index < 0 || index >= self.personas.count) {
NSIndexPath *indexPath = self.collectionView.indexPathsForVisibleItems.firstObject;
if (indexPath) {
index = indexPath.item;
} else {
index = 0;
}
}
KBPersonaModel *persona = self.personas[index];
return persona.personaId;
}
#pragma mark - Lazy Load
- (UICollectionView *)collectionView {
@@ -290,7 +309,21 @@
}
NSLog(@"[KBAIHomeVC] 语音识别结果:%@", text);
// TODO: 使
NSInteger companionId = [self currentCompanionId];
if (companionId <= 0) {
NSLog(@"[KBAIHomeVC] companionId 无效,取消请求");
return;
}
[self.aiVM requestChatMessageWithContent:text
companionId:companionId
completion:^(KBAiMessageResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
NSLog(@"[KBAIHomeVC] 请求聊天失败:%@", error.localizedDescription);
return;
}
NSLog(@"[KBAIHomeVC] 聊天请求成功code=%ld", (long)response.code);
}];
}
- (void)voiceToTextManager:(KBVoiceToTextManager *)manager