Spaces:
Runtime error
Runtime error
conflict
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"]
|
@@ -58,10 +58,18 @@ def call_generate_text(message, history):
|
|
58 |
print(history)
|
59 |
|
60 |
#messages = history + message
|
|
|
61 |
messages =history + [{"role":"user","content":message}]
|
62 |
try:
|
63 |
text = generate_text(history)
|
64 |
#history.append({"role": "assistant", "content": text})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
return text
|
66 |
except RuntimeError as e:
|
67 |
print(f"An unexpected error occurred: {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"]
|
|
|
58 |
print(history)
|
59 |
|
60 |
#messages = history + message
|
61 |
+
<<<<<<< HEAD
|
62 |
messages =history + [{"role":"user","content":message}]
|
63 |
try:
|
64 |
text = generate_text(history)
|
65 |
#history.append({"role": "assistant", "content": text})
|
66 |
+
=======
|
67 |
+
# messages = [{"role":"user","content":message}]
|
68 |
+
messages = history+[{"role":"user","content":message}]
|
69 |
+
try:
|
70 |
+
text = generate_text(messages)
|
71 |
+
history.append({"role": "assistant", "content": text})
|
72 |
+
>>>>>>> 82325f6d06d848b6c1600ce2902018538b68230b
|
73 |
return text
|
74 |
except RuntimeError as e:
|
75 |
print(f"An unexpected error occurred: {e}")
|