amirgame197 commited on
Commit
9cff5d9
·
verified ·
1 Parent(s): 21544ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -26,7 +26,7 @@ def translate_to_english(prompt):
26
  translated_prompt = GoogleTranslator(source='auto', target='en').translate(prompt)
27
  return translated_prompt
28
 
29
- def translate_to_persian(response):
30
  translated_response = GoogleTranslator(source='auto', target='fa').translate(response)
31
  return translated_response
32
 
@@ -84,7 +84,7 @@ def chat_inf(system_prompt, prompt, history, memory, client_choice, seed, temp,
84
  for response in stream:
85
  output += response.token.text
86
  if translate_to_persian:
87
- output = translate_to_persian(output)
88
  yield [(prompt, output)], memory
89
  history.append((prompt, output))
90
  memory.append((prompt, output))
@@ -133,8 +133,8 @@ with gr.Blocks() as app:
133
  client_choice.change(load_models, client_choice, [chat_b])
134
  app.load(load_models, client_choice, [chat_b])
135
 
136
- chat_sub = inp.submit(check_rand, [rand, seed], seed).then(chat_inf, [sys_inp, inp, chat_b, memory, client_choice, seed, temp, tokens, top_p, rep_p, chat_mem, custom_prompt, translate_to_persian_checkbox], [chat_b, memory])
137
- go = btn.click(check_rand, [rand, seed], seed).then(chat_inf, [sys_inp, inp, chat_b, memory, client_choice, seed, temp, tokens, top_p, rep_p, chat_mem, custom_prompt, translate_to_persian_checkbox], [chat_b, memory])
138
 
139
  clear_btn.click(clear_fn, None, [inp, sys_inp, chat_b, memory])
140
  app.queue(default_concurrency_limit=10).launch()
 
26
  translated_prompt = GoogleTranslator(source='auto', target='en').translate(prompt)
27
  return translated_prompt
28
 
29
+ def translate_to_persian_text(response):
30
  translated_response = GoogleTranslator(source='auto', target='fa').translate(response)
31
  return translated_response
32
 
 
84
  for response in stream:
85
  output += response.token.text
86
  if translate_to_persian:
87
+ output = translate_to_persian_text(output)
88
  yield [(prompt, output)], memory
89
  history.append((prompt, output))
90
  memory.append((prompt, output))
 
133
  client_choice.change(load_models, client_choice, [chat_b])
134
  app.load(load_models, client_choice, [chat_b])
135
 
136
+ chat_sub = inp.submit(check_rand, [rand, seed], seed).then(chat_inf, [sys_inp, inp, chat_b, memory, client_choice, seed, temp, tokens, top_p, rep_p, chat_mem, custom_prompt, translate_to_persian_checkbox.value], [chat_b, memory])
137
+ go = btn.click(check_rand, [rand, seed], seed).then(chat_inf, [sys_inp, inp, chat_b, memory, client_choice, seed, temp, tokens, top_p, rep_p, chat_mem, custom_prompt, translate_to_persian_checkbox.value], [chat_b, memory])
138
 
139
  clear_btn.click(clear_fn, None, [inp, sys_inp, chat_b, memory])
140
  app.queue(default_concurrency_limit=10).launch()