mrbui1990 commited on
Commit
5099a19
·
verified ·
1 Parent(s): 4c4cbf7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -26,6 +26,7 @@ model_trans = AutoModelForCausalLM.from_pretrained(
26
 
27
  # --- Sửa đổi hàm translate_text ---
28
  # Thêm tham số model_name (mặc định là "quickmt-en-vi")
 
29
  def translate_text(text, lang=None, progress=gr.Progress(track_tqdm=True)):
30
  # Set default values if None (happens during example caching)
31
  if lang is None:
@@ -201,7 +202,13 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
201
  label="",
202
  placeholder="",
203
  lines=1
204
- )
 
 
 
 
 
 
205
 
206
  with gr.Row():
207
  clear_button = gr.Button("Clear Chat")
@@ -225,6 +232,12 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
225
  outputs=[prompt_box, chatbot_display, internal_history, response, prompt]
226
  )
227
 
 
 
 
 
 
 
228
  # Khi người dùng nhấn nút "Send" (ẩn)
229
  submit_button.click(
230
  fn=chat_with_model,
 
26
 
27
  # --- Sửa đổi hàm translate_text ---
28
  # Thêm tham số model_name (mặc định là "quickmt-en-vi")
29
+ @spaces.GPU(duration=60)
30
  def translate_text(text, lang=None, progress=gr.Progress(track_tqdm=True)):
31
  # Set default values if None (happens during example caching)
32
  if lang is None:
 
202
  label="",
203
  placeholder="",
204
  lines=1
205
+ )
206
+
207
+ text_translate = gr.Textbox(
208
+ label="",
209
+ placeholder="",
210
+ lines=1
211
+ )
212
 
213
  with gr.Row():
214
  clear_button = gr.Button("Clear Chat")
 
232
  outputs=[prompt_box, chatbot_display, internal_history, response, prompt]
233
  )
234
 
235
+ text_translate.submit(
236
+ fn=translate_text,
237
+ inputs=[text_translate,lang],
238
+ outputs=[prompt]
239
+ )
240
+
241
  # Khi người dùng nhấn nút "Send" (ẩn)
242
  submit_button.click(
243
  fn=chat_with_model,