添加个人主页
This commit is contained in:
@@ -164,6 +164,14 @@ typedef void (^AiVMSpeechTranscribeCompletion)(KBAiSpeechTranscribeResponse *_Nu
|
||||
- (void)resetChatSessionWithCompanionId:(NSInteger)companionId
|
||||
completion:(void(^)(KBChatSessionResetResponse * _Nullable response, NSError * _Nullable error))completion;
|
||||
|
||||
#pragma mark - AI 角色详情接口
|
||||
|
||||
/// 根据 ID 获取 AI 角色详情
|
||||
/// @param companionId AI 角色 ID
|
||||
/// @param completion 完成回调(返回角色详情)
|
||||
- (void)fetchCompanionDetailWithCompanionId:(NSInteger)companionId
|
||||
completion:(void(^)(KBAICompanionDetailModel * _Nullable detail, NSError * _Nullable error))completion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#import "KBLikedCompanionModel.h"
|
||||
#import "KBChattedCompanionModel.h"
|
||||
#import "KBChatSessionResetModel.h"
|
||||
#import "KBAICompanionDetailModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
|
||||
@implementation KBAiSyncData
|
||||
@@ -753,4 +754,58 @@ autoShowBusinessError:NO
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - AI 角色详情接口
|
||||
|
||||
- (void)fetchCompanionDetailWithCompanionId:(NSInteger)companionId
|
||||
completion:(void (^)(KBAICompanionDetailModel * _Nullable, NSError * _Nullable))completion {
|
||||
NSString *path = [NSString stringWithFormat:@"/ai-companion/%ld", (long)companionId];
|
||||
|
||||
NSLog(@"[AiVM] %@ request", path);
|
||||
[[KBNetworkManager shared]
|
||||
GET:path
|
||||
parameters:nil
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary *_Nullable json,
|
||||
NSURLResponse *_Nullable response,
|
||||
NSError *_Nullable error) {
|
||||
if (error) {
|
||||
NSLog(@"[AiVM] %@ failed: %@", path, error.localizedDescription ?: @"");
|
||||
if (completion) {
|
||||
completion(nil, error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[AiVM] %@ response: %@", path, json);
|
||||
|
||||
NSInteger code = [json[@"code"] integerValue];
|
||||
if (code != 0) {
|
||||
NSString *message = json[@"message"] ?: @"请求失败";
|
||||
NSError *bizError = [NSError errorWithDomain:@"AiVM"
|
||||
code:code
|
||||
userInfo:@{NSLocalizedDescriptionKey: message}];
|
||||
if (completion) {
|
||||
completion(nil, bizError);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
id dataObj = json[@"data"];
|
||||
if ([dataObj isKindOfClass:[NSDictionary class]]) {
|
||||
KBAICompanionDetailModel *detail = [KBAICompanionDetailModel mj_objectWithKeyValues:dataObj];
|
||||
if (completion) {
|
||||
completion(detail, nil);
|
||||
}
|
||||
} else {
|
||||
NSError *parseError = [NSError errorWithDomain:@"AiVM"
|
||||
code:-1
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"数据格式错误"}];
|
||||
if (completion) {
|
||||
completion(nil, parseError);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user