Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -45,15 +45,14 @@ streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_
|
|
45 |
|
46 |
@spaces.GPU(duration=59)
|
47 |
def chat(message: str,
|
48 |
-
history: list,
|
49 |
temperature: float,
|
50 |
max_new_tokens: int,
|
51 |
progress=gr.Progress(track_tqdm=True)
|
52 |
):
|
53 |
try:
|
54 |
-
|
55 |
-
|
56 |
-
else: history.extend(conversation)
|
57 |
|
58 |
input_tensors = tokenizer.apply_chat_template(history, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(model.device)
|
59 |
|
|
|
45 |
|
46 |
@spaces.GPU(duration=59)
|
47 |
def chat(message: str,
|
48 |
+
history: list[dict],
|
49 |
temperature: float,
|
50 |
max_new_tokens: int,
|
51 |
progress=gr.Progress(track_tqdm=True)
|
52 |
):
|
53 |
try:
|
54 |
+
if not history: history = []
|
55 |
+
history.append({"role": "user", "content": message})
|
|
|
56 |
|
57 |
input_tensors = tokenizer.apply_chat_template(history, add_generation_prompt=True, return_dict=True, return_tensors="pt").to(model.device)
|
58 |
|