rushankg commited on
Commit
d446c1e
·
verified ·
1 Parent(s): d158697

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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
- 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__":
 
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__":