AlanXian commited on
Commit
57670ba
·
1 Parent(s): f8d057d

update zhou

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -78,13 +78,17 @@ def chat_llama3_8b(message: str,
78
  for user, assistant in history:
79
  history_messages.extend(assistant)
80
 
81
- conversation = [
82
- message, # 当前消息
83
- history_messages # 历史消息数组
84
- ]
85
-
86
- input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
 
 
87
 
 
 
88
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
89
 
90
  generate_kwargs = dict(
 
78
  for user, assistant in history:
79
  history_messages.extend(assistant)
80
 
81
+ # conversation = [
82
+ # message, # 当前消息
83
+ # history_messages # 历史消息数组
84
+ # ]
85
+ conversation = ""
86
+ for user, assistant in history:
87
+ conversation += f"User: {user}\nAssistant: {assistant}<|endoftext|>\n"
88
+ conversation += f"User: {message}\nAssistant: "
89
 
90
+ tokenizer.chat_template = "User:{query}\nAssistant:{response}<|endoftext|>"
91
+ input_ids = tokenizer.encode(conversation, return_tensors="pt").to(model.device)
92
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
93
 
94
  generate_kwargs = dict(