ysharma HF staff commited on
Commit
c57a974
·
verified ·
1 Parent(s): 16c4fb3

fixed history handling

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -47,7 +47,12 @@ def codegemma(message: str,
47
  Returns:
48
  str: The generated response.
49
  """
50
- input_ids = tokenizer.encode(message, return_tensors="pt").to(model.device)
 
 
 
 
 
51
 
52
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
53
 
 
47
  Returns:
48
  str: The generated response.
49
  """
50
+ conversation = []
51
+ for user, assistant in history:
52
+ conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
53
+ conversation.append({"role": "user", "content": message})
54
+
55
+ input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
56
 
57
  streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
58