arad1367 commited on
Commit
770dcc9
1 Parent(s): 56b0657

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -15
app.py CHANGED
@@ -64,29 +64,25 @@ def stream_chat(
64
  print(f'message: {message}')
65
  print(f'history: {history}')
66
 
67
- conversation = [
68
- {"role": "system", "content": system_prompt}
69
- ]
70
  for prompt, answer in history:
71
- conversation.extend([
72
- {"role": "user", "content": prompt},
73
- {"role": "assistant", "content": answer},
74
- ])
75
 
76
- conversation.append({"role": "user", "content": message})
77
 
78
- input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt").to(model.device)
79
 
80
  streamer = TextIteratorStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
81
 
82
  generate_kwargs = dict(
83
  input_ids=input_ids,
84
- max_new_tokens = max_new_tokens,
85
- do_sample = False if temperature == 0 else True,
86
- top_p = top_p,
87
- top_k = top_k,
88
- temperature = temperature,
89
- eos_token_id=[128001,128008,128009],
90
  streamer=streamer,
91
  )
92
 
 
64
  print(f'message: {message}')
65
  print(f'history: {history}')
66
 
67
+ conversation = [system_prompt]
 
 
68
  for prompt, answer in history:
69
+ conversation.append(prompt)
70
+ conversation.append(answer)
 
 
71
 
72
+ conversation.append(message)
73
 
74
+ input_ids = tokenizer(conversation, return_tensors="pt").input_ids.to(model.device)
75
 
76
  streamer = TextIteratorStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
77
 
78
  generate_kwargs = dict(
79
  input_ids=input_ids,
80
+ max_new_tokens=max_new_tokens,
81
+ do_sample=False if temperature == 0 else True,
82
+ top_p=top_p,
83
+ top_k=top_k,
84
+ temperature=temperature,
85
+ eos_token_id=[128001, 128008, 128009],
86
  streamer=streamer,
87
  )
88