haidlir commited on
Commit
a626a37
1 Parent(s): 011d8a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -10,6 +10,8 @@ def predict(message, history):
10
  for human, assistant in history:
11
  history_chatml_format.append({"role": "user", "content": human })
12
  history_chatml_format.append({"role": "assistant", "content":assistant})
 
 
13
  history_chatml_format.append({"role": "user", "content": message})
14
 
15
  model_inputs = tokenizer.apply_chat_template(
@@ -22,6 +24,7 @@ def predict(message, history):
22
  generated_text = model.generate(input_ids=model_inputs,
23
  generation_config=GenerationConfig(max_new_tokens=512),
24
  )
25
- return tokenizer.decode(generated_text[0], skip_special_tokens=True)
 
26
 
27
  gr.ChatInterface(predict).launch()
 
10
  for human, assistant in history:
11
  history_chatml_format.append({"role": "user", "content": human })
12
  history_chatml_format.append({"role": "assistant", "content":assistant})
13
+ prefix = "Kamu adalah BaGoEs, sebuah chatbot. Beri jawaban pendek dan singkat."
14
+ history_chatml_format.append({"role": "system", "content": prefix})
15
  history_chatml_format.append({"role": "user", "content": message})
16
 
17
  model_inputs = tokenizer.apply_chat_template(
 
24
  generated_text = model.generate(input_ids=model_inputs,
25
  generation_config=GenerationConfig(max_new_tokens=512),
26
  )
27
+ len_input = len(model_inputs[0])
28
+ return tokenizer.decode(generated_text[0][len_input:], skip_special_tokens=True).strip()
29
 
30
  gr.ChatInterface(predict).launch()