diff --git a/Easydict/Feature/Service/OpenAI/EZOpenAIService.m b/Easydict/Feature/Service/OpenAI/EZOpenAIService.m index 511739a8c..01dfca1f2 100644 --- a/Easydict/Feature/Service/OpenAI/EZOpenAIService.m +++ b/Easydict/Feature/Service/OpenAI/EZOpenAIService.m @@ -553,12 +553,23 @@ - (NSString *)parseContentFromStreamData:(NSData *)data if (delta) { if (delta[@"content"]) { NSString *content = delta[@"content"]; -// NSLog(@"delta content: %@", content); - [mutableString appendString:content]; + // NSLog(@"delta content: %@", content); + + /** + SIGABRT: -[NSNull length]: unrecognized selector sent to instance 0x1dff03ce0 + + -[__NSCFString appendString:] + -[EZOpenAIService parseContentFromStreamData:lastData:error:isFinished:] EZOpenAIService.m:536 + */ + if ([content isKindOfClass:NSString.class]) { + [mutableString appendString:content]; + } } // finish_reason is string or null NSString *finishReason = choice[@"finish_reason"]; + + // Fix: SIGABRT: -[NSNull length]: unrecognized selector sent to instance 0x1dff03ce0 if ([finishReason isKindOfClass:NSString.class] && finishReason.length) { NSLog(@"finish reason: %@", finishReason);