Spaces:
Runtime error
Runtime error
test
Browse files
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,
|