Spaces:
Running
Running
fix genai
Browse files- 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 |
-
|
21 |
-
|
22 |
-
|
|
|
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:
|