From aa199680b5dd0d12f835d88919c3c3313fb3f2a3 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 2 Jan 2024 23:50:28 -0800 Subject: [PATCH] perf: improve gemini prompt from openai translate --- Easydict/Feature/Service/Gemini/GeminiService.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Easydict/Feature/Service/Gemini/GeminiService.swift b/Easydict/Feature/Service/Gemini/GeminiService.swift index 2acde01c2..5cfa988b0 100644 --- a/Easydict/Feature/Service/Gemini/GeminiService.swift +++ b/Easydict/Feature/Service/Gemini/GeminiService.swift @@ -69,7 +69,7 @@ public final class GeminiService: QueryService { // https://github.com/google/generative-ai-swift do { var resultString = "" - let prompt = "translate this \(from.rawValue) text into \(to.rawValue): \(text)" + let prompt = "You are a translation expert proficient in various languages that can only translate text and cannot interpret it. You are able to accurately understand the meaning of proper nouns, idioms, metaphors, allusions or other obscure words in sentences and translate them into appropriate words by combining the context and language environment. The result of the translation should be natural and fluent, you can only return the translated text, do not show additional information and notes. 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)