Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import time
|
|
| 8 |
import os
|
| 9 |
from typing import Iterator, List, Tuple
|
| 10 |
import spaces
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
|
|
@@ -133,7 +134,9 @@ class SinaReasonMedicalChat:
|
|
| 133 |
|
| 134 |
# Start generation directly.
|
| 135 |
# This will return immediately and the streamer will be populated in the background.
|
| 136 |
-
self.model.generate(**generation_kwargs)
|
|
|
|
|
|
|
| 137 |
|
| 138 |
# Stream the response
|
| 139 |
partial_response = ""
|
|
@@ -143,7 +146,7 @@ class SinaReasonMedicalChat:
|
|
| 143 |
for new_token in streamer:
|
| 144 |
partial_response += new_token
|
| 145 |
|
| 146 |
-
|
| 147 |
# Extract thinking and response
|
| 148 |
thinking, response = self.extract_thinking_and_response(partial_response)
|
| 149 |
|
|
|
|
| 8 |
import os
|
| 9 |
from typing import Iterator, List, Tuple
|
| 10 |
import spaces
|
| 11 |
+
import threading
|
| 12 |
|
| 13 |
|
| 14 |
|
|
|
|
| 134 |
|
| 135 |
# Start generation directly.
|
| 136 |
# This will return immediately and the streamer will be populated in the background.
|
| 137 |
+
#self.model.generate(**generation_kwargs)
|
| 138 |
+
thread = threading.Thread(target=self.model.generate, kwargs=generation_kwargs)
|
| 139 |
+
thread.start()
|
| 140 |
|
| 141 |
# Stream the response
|
| 142 |
partial_response = ""
|
|
|
|
| 146 |
for new_token in streamer:
|
| 147 |
partial_response += new_token
|
| 148 |
|
| 149 |
+
print(partial_response)
|
| 150 |
# Extract thinking and response
|
| 151 |
thinking, response = self.extract_thinking_and_response(partial_response)
|
| 152 |
|