Spaces:
Runtime error
Runtime error
πwπ
Browse files
app.py
CHANGED
@@ -76,9 +76,8 @@ def talk(message, history):
|
|
76 |
messages = tokenizer.apply_chat_template(
|
77 |
chat, tokenize=False, add_generation_prompt=True
|
78 |
)
|
79 |
-
|
80 |
-
|
81 |
-
yield partial_text
|
82 |
# Tokenize the messages string
|
83 |
model_inputs = tokenizer([messages], return_tensors="pt").to(device)
|
84 |
streamer = TextIteratorStreamer(
|
@@ -94,11 +93,14 @@ def talk(message, history):
|
|
94 |
temperature=0.75,
|
95 |
num_beams=1,
|
96 |
)
|
|
|
97 |
t = Thread(target=model.generate, kwargs=generate_kwargs)
|
98 |
t.start()
|
99 |
|
|
|
|
|
100 |
for new_text in streamer:
|
101 |
-
if new_text is not None
|
102 |
partial_text += new_text
|
103 |
yield partial_text
|
104 |
partial_text += resources
|
|
|
76 |
messages = tokenizer.apply_chat_template(
|
77 |
chat, tokenize=False, add_generation_prompt=True
|
78 |
)
|
79 |
+
print("chat template prepared, ", messages)
|
80 |
+
print("tokenizing input ...")
|
|
|
81 |
# Tokenize the messages string
|
82 |
model_inputs = tokenizer([messages], return_tensors="pt").to(device)
|
83 |
streamer = TextIteratorStreamer(
|
|
|
93 |
temperature=0.75,
|
94 |
num_beams=1,
|
95 |
)
|
96 |
+
print("initializing thread ...")
|
97 |
t = Thread(target=model.generate, kwargs=generate_kwargs)
|
98 |
t.start()
|
99 |
|
100 |
+
# Initialize an empty string to store the generated text
|
101 |
+
partial_text = ""
|
102 |
for new_text in streamer:
|
103 |
+
if new_text is not None:
|
104 |
partial_text += new_text
|
105 |
yield partial_text
|
106 |
partial_text += resources
|