Spaces:
Runtime error
Runtime error
fixed history handling
Browse files
app.py
CHANGED
@@ -47,7 +47,12 @@ def codegemma(message: str,
|
|
47 |
Returns:
|
48 |
str: The generated response.
|
49 |
"""
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
53 |
|
|
|
47 |
Returns:
|
48 |
str: The generated response.
|
49 |
"""
|
50 |
+
conversation = []
|
51 |
+
for user, assistant in history:
|
52 |
+
conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
53 |
+
conversation.append({"role": "user", "content": message})
|
54 |
+
|
55 |
+
input_ids = tokenizer.apply_chat_template(conversation, return_tensors="pt").to(model.device)
|
56 |
|
57 |
streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
58 |
|