Spaces:
Paused
Paused
Reverting to the older non streaming method
Browse files
app.py
CHANGED
|
@@ -7,7 +7,7 @@ model_id = "Qwen/Qwen2.5-0.5B-Instruct"
|
|
| 7 |
pipe = pipeline("text-generation", model=model_id, device_map="auto") #adding a auto detect gpu
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 9 |
|
| 10 |
-
def
|
| 11 |
# 1. Format the conversation using the official template
|
| 12 |
messages = [{"role": "user", "content": message},
|
| 13 |
{"role": "system", "content": "Use context if relevant, otherwise answer generally."},]
|
|
@@ -31,7 +31,8 @@ def chat_old(message, history):
|
|
| 31 |
from threading import Thread
|
| 32 |
from transformers import TextIteratorStreamer
|
| 33 |
model = pipe.model
|
| 34 |
-
|
|
|
|
| 35 |
messages = [{"role": "user", "content": message},
|
| 36 |
{"role": "system", "content": "Use context if relevant, otherwise answer generally."},]
|
| 37 |
|
|
|
|
| 7 |
pipe = pipeline("text-generation", model=model_id, device_map="auto") #adding a auto detect gpu
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 9 |
|
| 10 |
+
def chat(message, history):
|
| 11 |
# 1. Format the conversation using the official template
|
| 12 |
messages = [{"role": "user", "content": message},
|
| 13 |
{"role": "system", "content": "Use context if relevant, otherwise answer generally."},]
|
|
|
|
| 31 |
from threading import Thread
|
| 32 |
from transformers import TextIteratorStreamer
|
| 33 |
model = pipe.model
|
| 34 |
+
#reverting back to original non streaming method
|
| 35 |
+
def chat_new(message, history):
|
| 36 |
messages = [{"role": "user", "content": message},
|
| 37 |
{"role": "system", "content": "Use context if relevant, otherwise answer generally."},]
|
| 38 |
|