mrbui1990 commited on
Commit
281cf2d
·
verified ·
1 Parent(s): 70f48c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -94,8 +94,10 @@ def chat_with_model(prompt, system_prompt, chatbot_display, internal_history,lan
94
  print("❌ Invalid key.")
95
  return "", chatbot_display, internal_history
96
  prompt = prompt.replace(expected_key, "")
 
97
  if "[AUTO]" in prompt:
98
  prompt = prompt.replace("[AUTO]", "")
 
99
  else:
100
  if lang != None:
101
  prompt = translate_text(prompt,"English")
@@ -139,11 +141,12 @@ def chat_with_model(prompt, system_prompt, chatbot_display, internal_history,lan
139
  # 5. Decode *chỉ* phần trả lời mới
140
  response_text = tokenizer.decode(output_tokens[0][inputs.shape[-1]:], skip_special_tokens=True)
141
  translated = response_text
142
- if lang != None :
143
- if gender :
144
- translated = translate_text(response_text+"; Mr Tuan",lang)
145
- else:
146
- translated = translate_text(response_text +"; Ms Jenny",lang)
 
147
  print("response_text : "+response_text)
148
  print("translated : "+translated)
149
  # 6. Cập nhật "bộ nhớ" (gr.State) với lượt nói MỚI
 
94
  print("❌ Invalid key.")
95
  return "", chatbot_display, internal_history
96
  prompt = prompt.replace(expected_key, "")
97
+ isAuto = False
98
  if "[AUTO]" in prompt:
99
  prompt = prompt.replace("[AUTO]", "")
100
+ isAuto = True
101
  else:
102
  if lang != None:
103
  prompt = translate_text(prompt,"English")
 
141
  # 5. Decode *chỉ* phần trả lời mới
142
  response_text = tokenizer.decode(output_tokens[0][inputs.shape[-1]:], skip_special_tokens=True)
143
  translated = response_text
144
+ if isAuto is None:
145
+ if lang != None :
146
+ if gender :
147
+ translated = translate_text(response_text+"; Mr Tuan",lang)
148
+ else:
149
+ translated = translate_text(response_text +"; Ms Jenny",lang)
150
  print("response_text : "+response_text)
151
  print("translated : "+translated)
152
  # 6. Cập nhật "bộ nhớ" (gr.State) với lượt nói MỚI