ZhehanZ commited on
Commit
5fb739a
1 Parent(s): 5cbf2ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -8,12 +8,12 @@ import openai
8
  class TranslationAgent:
9
  def __init__(self, openai_key):
10
  self.memory = []
11
- system_msg = "You are a translator from english to italian.\n" \
12
  " The only thing you do is to translate.\n" \
13
  " You don't write anything other then the translation of the text you get.\n" \
14
  " The user will only provide the text without asking anything, but what he wants is the translation.\n" \
15
  " Never return the translation of a previously translated part!\n " \
16
- "The text you will need to translate will often include none sense stuff because it is coming from a text extraction of a pdf file including images and table.\n" \
17
  " Do your best to translate also this messy parts."
18
 
19
  self.memory.append({"role": "system", "content": system_msg})
@@ -27,7 +27,7 @@ class TranslationAgent:
27
  def translate_chunk(self, chunk):
28
  self.memory.append({"role": "user", "content": chunk})
29
  response = openai.ChatCompletion.create(
30
- model="gpt-3.5-turbo",
31
  messages=self.memory
32
  )
33
  reply = response["choices"][0]["message"]["content"]
@@ -106,7 +106,7 @@ iface = gr.Interface(
106
  gr.Number(label="Final Page")
107
  ],
108
  outputs=["text", "text", gr.File(label="Translated Text File")],
109
- title="Pdf Translator: English ==> Italian",
110
  )
111
 
112
  iface.launch()
 
8
  class TranslationAgent:
9
  def __init__(self, openai_key):
10
  self.memory = []
11
+ system_msg = "You are a translator from english to chinese (简体中文).\n" \
12
  " The only thing you do is to translate.\n" \
13
  " You don't write anything other then the translation of the text you get.\n" \
14
  " The user will only provide the text without asking anything, but what he wants is the translation.\n" \
15
  " Never return the translation of a previously translated part!\n " \
16
+ " The text you will need to translate will often include nonesense stuff because it is coming from a text extraction of a pdf file including images and table.\n" \
17
  " Do your best to translate also this messy parts."
18
 
19
  self.memory.append({"role": "system", "content": system_msg})
 
27
  def translate_chunk(self, chunk):
28
  self.memory.append({"role": "user", "content": chunk})
29
  response = openai.ChatCompletion.create(
30
+ model="gpt-4-turbo-preview",
31
  messages=self.memory
32
  )
33
  reply = response["choices"][0]["message"]["content"]
 
106
  gr.Number(label="Final Page")
107
  ],
108
  outputs=["text", "text", gr.File(label="Translated Text File")],
109
+ title="Pdf Translator: English ==> Chinese",
110
  )
111
 
112
  iface.launch()