Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,7 @@ def generate_text(messages):
|
|
36 |
# model_id, token=huggingface_token ,torch_dtype=dtype,device_map=device
|
37 |
# )
|
38 |
|
39 |
-
text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer,torch_dtype=dtype,device_map=device) #pipeline has not to(device)
|
40 |
result = text_generator(messages, max_new_tokens=256, do_sample=True, temperature=0.7)
|
41 |
|
42 |
generated_output = result[0]["generated_text"]
|
@@ -59,8 +59,9 @@ def call_generate_text(message, history):
|
|
59 |
|
60 |
#messages = history + message
|
61 |
# messages = [{"role":"user","content":message}]
|
|
|
62 |
try:
|
63 |
-
text = generate_text(
|
64 |
history.append({"role": "assistant", "content": text})
|
65 |
return text
|
66 |
except RuntimeError as e:
|
|
|
36 |
# model_id, token=huggingface_token ,torch_dtype=dtype,device_map=device
|
37 |
# )
|
38 |
|
39 |
+
#text_generator = pipeline("text-generation", model=model, tokenizer=tokenizer,torch_dtype=dtype,device_map=device) #pipeline has not to(device)
|
40 |
result = text_generator(messages, max_new_tokens=256, do_sample=True, temperature=0.7)
|
41 |
|
42 |
generated_output = result[0]["generated_text"]
|
|
|
59 |
|
60 |
#messages = history + message
|
61 |
# messages = [{"role":"user","content":message}]
|
62 |
+
messages = history+[{"role":"user","content":message}]
|
63 |
try:
|
64 |
+
text = generate_text(messages)
|
65 |
history.append({"role": "assistant", "content": text})
|
66 |
return text
|
67 |
except RuntimeError as e:
|