John6666 commited on
Commit
5d07c9b
·
verified ·
1 Parent(s): 8c30c71

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -45,15 +45,14 @@ streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_
45
 
46
  @spaces.GPU(duration=59)
47
  def chat(message: str,
48
- history: list,
49
  temperature: float,
50
  max_new_tokens: int,
51
  progress=gr.Progress(track_tqdm=True)
52
  ):
53
  try:
54
- conversation = [{"role": "user", "content": message}]
55
- if len(history) == 0: history = conversation
56
- else: history.extend(conversation)
57
 
58
  input_tensors = tokenizer.apply_chat_template(history, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(model.device)
59
 
 
45
 
46
  @spaces.GPU(duration=59)
47
  def chat(message: str,
48
+ history: list[dict],
49
  temperature: float,
50
  max_new_tokens: int,
51
  progress=gr.Progress(track_tqdm=True)
52
  ):
53
  try:
54
+ if not history: history = []
55
+ history.append({"role": "user", "content": message})
 
56
 
57
  input_tensors = tokenizer.apply_chat_template(history, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(model.device)
58