From 20c617e956d4a0c4e0dad0ea7a92b6481340dcf0 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 2 Jan 2024 23:26:50 -0800 Subject: [PATCH] perf: restore CaiyunService --- .../Service/Caiyun/CaiyunService.swift | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/Easydict/Feature/Service/Caiyun/CaiyunService.swift b/Easydict/Feature/Service/Caiyun/CaiyunService.swift index 800ecded6..2c6b3dcf3 100644 --- a/Easydict/Feature/Service/Caiyun/CaiyunService.swift +++ b/Easydict/Feature/Service/Caiyun/CaiyunService.swift @@ -8,7 +8,6 @@ import Alamofire import Foundation -import GoogleGenerativeAI @objc(EZCaiyunService) public final class CaiyunService: QueryService { @@ -80,9 +79,6 @@ public final class CaiyunService: QueryService { "x-authorization": "token " + token, ] - geminiTranslate(text, from: from, to: to, completion: completion) - return - let request = AF.request(apiEndPoint, method: .post, parameters: parameters, @@ -110,34 +106,6 @@ public final class CaiyunService: QueryService { request.cancel() }, serviceType: serviceType().rawValue) } - - public func geminiTranslate(_ text: String, from: Language, to: Language, completion: @escaping (EZQueryResult, Error?) -> Void) { - Task { - // https://github.com/google/generative-ai-swift - do { - var resultString = "" - let prompt = "translate this \(from.rawValue) text into \(to.rawValue): \(text)" - print("gemini prompt: \(prompt)") - let model = GenerativeModel(name: "gemini-pro", apiKey: "") - 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 - result.translatedResults = [resultString] - completion(result, nil) - } - } catch { - print(error.localizedDescription) - completion(result, error) - } - } - } } enum QueryServiceError: Error {