Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,14 +34,16 @@ def main():
|
|
34 |
|
35 |
# Function to translate text using GPT-3.5
|
36 |
def translate_text(text, input_language, output_language):
|
37 |
-
|
38 |
-
response = openai.Completion.create(
|
39 |
model="gpt-3.5-turbo",
|
40 |
-
|
|
|
|
|
|
|
41 |
max_tokens=500,
|
42 |
-
temperature=0
|
43 |
)
|
44 |
-
translation = response.choices[0].
|
45 |
return translation
|
46 |
|
47 |
if __name__ == "__main__":
|
|
|
34 |
|
35 |
# Function to translate text using GPT-3.5
|
36 |
def translate_text(text, input_language, output_language):
|
37 |
+
response = openai.ChatCompletion.create(
|
|
|
38 |
model="gpt-3.5-turbo",
|
39 |
+
messages=[
|
40 |
+
{"role": "system", "content": f"You translate user input from {input_language} to {output_language}"},
|
41 |
+
{"role": "user", "content": text}
|
42 |
+
],
|
43 |
max_tokens=500,
|
44 |
+
temperature=0
|
45 |
)
|
46 |
+
translation = response.choices[0].message['content'].strip()
|
47 |
return translation
|
48 |
|
49 |
if __name__ == "__main__":
|