Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,8 +15,7 @@ alpaca_prompt = """පහත දැක්වෙන්නේ යම් කාර
|
|
| 15 |
### ප්රතිචාරය:
|
| 16 |
{}"""
|
| 17 |
|
| 18 |
-
|
| 19 |
-
def infer(message, history, enable_history=False, max_new_tokens=512):
|
| 20 |
global model, tokenizer
|
| 21 |
|
| 22 |
if model is None:
|
|
@@ -73,12 +72,14 @@ def infer(message, history, enable_history=False, max_new_tokens=512):
|
|
| 73 |
|
| 74 |
if response_started:
|
| 75 |
yield partial_text
|
| 76 |
-
elif "### ප්රතිචාරය:" not in prompt:
|
| 77 |
-
# If prompt doesn't contain the marker, stream everything
|
| 78 |
-
yield partial_text
|
| 79 |
|
| 80 |
thread.join()
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
# Custom CSS for styling
|
| 83 |
custom_css = """
|
| 84 |
#splash-screen {
|
|
|
|
| 15 |
### ප්රතිචාරය:
|
| 16 |
{}"""
|
| 17 |
|
| 18 |
+
def infer_stream(message, history, enable_history=False, max_new_tokens=512):
|
|
|
|
| 19 |
global model, tokenizer
|
| 20 |
|
| 21 |
if model is None:
|
|
|
|
| 72 |
|
| 73 |
if response_started:
|
| 74 |
yield partial_text
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
thread.join()
|
| 77 |
|
| 78 |
+
@spaces.GPU
|
| 79 |
+
def infer(message, history, enable_history=False, max_new_tokens=512):
|
| 80 |
+
# Return the generator for streaming
|
| 81 |
+
return infer_stream(message, history, enable_history, max_new_tokens)
|
| 82 |
+
|
| 83 |
# Custom CSS for styling
|
| 84 |
custom_css = """
|
| 85 |
#splash-screen {
|