Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,20 +34,15 @@ def main():
|
|
| 34 |
|
| 35 |
# Function to translate text using GPT-3.5
|
| 36 |
def translate_text(text, input_language, output_language):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
translation = response.choices[0].message['content'].strip()
|
| 47 |
-
return translation
|
| 48 |
-
|
| 49 |
-
except Exception as e:
|
| 50 |
-
return f"Error: {str(e)}"
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
| 53 |
main()
|
|
|
|
| 34 |
|
| 35 |
# Function to translate text using GPT-3.5
|
| 36 |
def translate_text(text, input_language, output_language):
|
| 37 |
+
prompt = f"Translate the following from {input_language} to {output_language}:\n\n{text}"
|
| 38 |
+
response = openai.Completion.create(
|
| 39 |
+
model="gpt-3.5-turbo",
|
| 40 |
+
prompt=prompt,
|
| 41 |
+
max_tokens=500,
|
| 42 |
+
temperature=0.3
|
| 43 |
+
)
|
| 44 |
+
translation = response.choices[0].text.strip()
|
| 45 |
+
return translation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
main()
|