Skip to content

Commit

Permalink
fix: content streaming on macOS 12+
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry23011 committed Jan 26, 2024
1 parent 7ca612c commit fcc3b11
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Easydict/Feature/Service/Gemini/GeminiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public final class GeminiService: QueryService {

print("gemini response: \(line)")
resultString += line
result.translatedResults = [resultString]
completion(result, nil)
}

} else {
let outputContent = try await model.generateContent(prompt)
guard let line = outputContent.text else {
Expand All @@ -116,16 +119,15 @@ public final class GeminiService: QueryService {

print("gemini response: \(line)")
resultString += line
result.translatedResults = [resultString]
completion(result, nil)
}

result.translatedResults = [resultString]
completion(result, nil)
} catch {
/**
https://github.com/google/generative-ai-swift/issues/89

String(describing: error)

"internalError(underlying: GoogleGenerativeAI.RPCError(httpResponseCode: 400, message: \"API key not valid. Please pass a valid API key.\", status: GoogleGenerativeAI.RPCStatus.invalidArgument))"
*/
let ezError = EZError(nsError: error)
Expand Down

0 comments on commit fcc3b11

Please sign in to comment.