Spaces:
Sleeping
Sleeping
update zhou
Browse files
app.py
CHANGED
@@ -78,13 +78,17 @@ def chat_llama3_8b(message: str,
|
|
78 |
for user, assistant in history:
|
79 |
history_messages.extend(assistant)
|
80 |
|
81 |
-
conversation = [
|
82 |
-
|
83 |
-
|
84 |
-
]
|
85 |
-
|
86 |
-
|
|
|
|
|
87 |
|
|
|
|
|
88 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
89 |
|
90 |
generate_kwargs = dict(
|
|
|
78 |
for user, assistant in history:
|
79 |
history_messages.extend(assistant)
|
80 |
|
81 |
+
# conversation = [
|
82 |
+
# message, # 当前消息
|
83 |
+
# history_messages # 历史消息数组
|
84 |
+
# ]
|
85 |
+
conversation = ""
|
86 |
+
for user, assistant in history:
|
87 |
+
conversation += f"User: {user}\nAssistant: {assistant}<|endoftext|>\n"
|
88 |
+
conversation += f"User: {message}\nAssistant: "
|
89 |
|
90 |
+
tokenizer.chat_template = "User:{query}\nAssistant:{response}<|endoftext|>"
|
91 |
+
input_ids = tokenizer.encode(conversation, return_tensors="pt").to(model.device)
|
92 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
93 |
|
94 |
generate_kwargs = dict(
|