deepakaiplanet commited on
Commit
63accbf
·
verified ·
1 Parent(s): 8b49c77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -15
app.py CHANGED
@@ -27,9 +27,6 @@ system_prompt_1 = """
27
 
28
  transcribes text: """
29
 
30
- system_prompt_2 = """Please translate the following text field content in english langauge.
31
- text: {text}
32
- """
33
 
34
  def translate_text(file, text_input):
35
  llm = OpenAI()
@@ -41,20 +38,11 @@ def translate_text(file, text_input):
41
  prompt_1 = template_1.format(text=file_text)
42
  file_translation = llm(prompt_1)
43
 
44
- template_2 = PromptTemplate(input_variables=["text"], template=system_prompt_2)
45
- prompt_2 = template_2.format(text=file_translation)
46
- text_translation_op = llm(prompt_2)
47
-
48
-
49
- template_3 = PromptTemplate(input_variables=["text"], template=system_prompt_2)
50
- prompt_3 = template_2.format(text=file_text)
51
- text_translation_ip = llm(prompt_3)
52
-
53
  output_file_path = "translated_file.txt"
54
  with open(output_file_path, 'w', encoding='utf-8') as f:
55
  f.write(file_translation)
56
 
57
- return text_translation_ip, file_translation, text_translation_op, output_file_path
58
 
59
  iface = gr.Interface(
60
  fn=translate_text,
@@ -63,9 +51,7 @@ iface = gr.Interface(
63
 
64
  ],
65
  outputs=[
66
- gr.Textbox(label="transcribes content in english Translated of input content"),
67
  gr.Textbox(label="transcribes content"),
68
- gr.Textbox(label="transcribes content in english Translated of output content"),
69
  gr.File(label="Download Translated File Text")
70
 
71
  ],
 
27
 
28
  transcribes text: """
29
 
 
 
 
30
 
31
  def translate_text(file, text_input):
32
  llm = OpenAI()
 
38
  prompt_1 = template_1.format(text=file_text)
39
  file_translation = llm(prompt_1)
40
 
 
 
 
 
 
 
 
 
 
41
  output_file_path = "translated_file.txt"
42
  with open(output_file_path, 'w', encoding='utf-8') as f:
43
  f.write(file_translation)
44
 
45
+ return text_translation_ip, file_translation
46
 
47
  iface = gr.Interface(
48
  fn=translate_text,
 
51
 
52
  ],
53
  outputs=[
 
54
  gr.Textbox(label="transcribes content"),
 
55
  gr.File(label="Download Translated File Text")
56
 
57
  ],