mintlee commited on
Commit
4d949ca
·
1 Parent(s): 6ae64ab
Files changed (1) hide show
  1. translate/translator.py +4 -3
translate/translator.py CHANGED
@@ -17,9 +17,10 @@ def translate_text_dict(text_dict: Dict[str, List[str]], source_lang: str, targe
17
  Aim for brevity if possible so that the length of the translations match the length of the original texts, but prioritize accuracy above all .
18
  Return the translated texts formatted like the original dictionary. Do NOT say anthing else. Return it as a JSON block."""
19
 
20
- client = genai.Client(api_key=gemini_api)
21
- response = client.models.generate_content(
22
- model="gemini-2.0-flash", contents=prompt) # Use a model appropriate for your needs and API key. gemini-2.0-flash doesn't exist. 1.5-pro is a good general-purpose model.
 
23
 
24
  # Handle potential errors in the response, including rate limits and invalid JSON.
25
  try:
 
17
  Aim for brevity if possible so that the length of the translations match the length of the original texts, but prioritize accuracy above all .
18
  Return the translated texts formatted like the original dictionary. Do NOT say anthing else. Return it as a JSON block."""
19
 
20
+ genai.configure(api_key=gemini_api)
21
+ model = genai.GenerativeModel("gemini-1.5-flash")
22
+
23
+ response = model.generate_content(prompt) # Use a model appropriate for your needs and API key. gemini-2.0-flash doesn't exist. 1.5-pro is a good general-purpose model.
24
 
25
  # Handle potential errors in the response, including rate limits and invalid JSON.
26
  try: