EITD commited on
Commit
0f9c03b
·
1 Parent(s): 9e0025f
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -59,6 +59,13 @@ def respond(
59
  # add_generation_prompt = True, # Must add for generation
60
  # return_tensors = "pt",
61
  # )
 
 
 
 
 
 
 
62
  inputs = tokenizer.encode(messages, return_tensors='pt')
63
  # text_streamer = TextStreamer(tokenizer, skip_prompt = True)
64
  # for response in model.generate(input_ids = inputs, streamer = text_streamer, max_new_tokens = max_tokens, use_cache = True,
 
59
  # add_generation_prompt = True, # Must add for generation
60
  # return_tensors = "pt",
61
  # )
62
+ conversation = ''
63
+ for msg in messages:
64
+ if msg['role'] == 'user':
65
+ conversation += f"User: {msg['content']}\n"
66
+ elif msg['role'] == 'assistant':
67
+ conversation += f"Assistant: {msg['content']}\n"
68
+ conversation += "Assistant: "
69
  inputs = tokenizer.encode(messages, return_tensors='pt')
70
  # text_streamer = TextStreamer(tokenizer, skip_prompt = True)
71
  # for response in model.generate(input_ids = inputs, streamer = text_streamer, max_new_tokens = max_tokens, use_cache = True,