Skip to content

Commit

Permalink
perf: change min version back to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry23011 committed Jan 10, 2024
1 parent bf330be commit 3163dcb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3198,7 +3198,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.5.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.izual.Easydict-debug";
PRODUCT_MODULE_NAME = Easydict;
Expand Down Expand Up @@ -3238,7 +3238,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 2.5.0;
PRODUCT_BUNDLE_IDENTIFIER = com.izual.Easydict;
PRODUCT_MODULE_NAME = Easydict;
Expand Down
4 changes: 2 additions & 2 deletions Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/generative-ai-swift",
"state" : {
"revision" : "fead3038a70047a72ea2cf39e96d3add71c372de",
"version" : "0.4.4"
"revision" : "5cf2aae0f4d04b77fe7b2110da1145462ff92b84",
"version" : "0.4.6"
}
},
{
Expand Down
23 changes: 17 additions & 6 deletions Easydict/Feature/Service/Gemini/GeminiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,36 @@ public final class GeminiService: QueryService {

override public func translate(_ text: String, from: Language, to: Language, completion: @escaping (EZQueryResult, Error?) -> Void) {
Task {
// https://github.com/google/generative-ai-swift
do {
var resultString = ""
let prompt = GeminiService.translationPrompt + "Translate the following \(from.rawValue) text into \(to.rawValue): \(text)"
print("gemini prompt: \(prompt)")
let model = GenerativeModel(name: "gemini-pro", apiKey: apiKey)
let outputContentStream = model.generateContentStream(prompt)

// stream response
for try await outputContent in outputContentStream {
if #available(macOS 12.0, *) {
let outputContentStream = model.generateContentStream(prompt)

// stream response
for try await outputContent in outputContentStream {
guard let line = outputContent.text else {
return
}

print("gemini response: \(line)")
resultString += line
}
} else {
let outputContent = try await model.generateContent(prompt)
guard let line = outputContent.text else {
return
}

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

result.translatedResults = [resultString]
completion(result, nil)
} catch {
print(error.localizedDescription)
completion(result, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ + (NSString *)getDeviceModel {

/// Get device UUID, 4F07896A-1580-5270-A0E8-D7FA9DFA6868
+ (NSString *)getDeviceUUID {
io_service_t platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
CFStringRef uuidString = (CFStringRef)IORegistryEntryCreateCFProperty(platformExpert, CFSTR("IOPlatformUUID"), kCFAllocatorDefault, 0);
NSString *uuid = (__bridge NSString *)(uuidString);
IOObjectRelease(platformExpert);
Expand Down

0 comments on commit 3163dcb

Please sign in to comment.