Spaces:
Sleeping
Sleeping
Raphael Glon
commited on
wip
Browse filesSigned-off-by: Raphael Glon <oOraph@users.noreply.github.com>
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import spaces
|
| 2 |
|
| 3 |
import logging
|
|
@@ -55,7 +57,7 @@ def _ensure_loaded():
|
|
| 55 |
_device = next(_model.parameters()).device
|
| 56 |
|
| 57 |
|
| 58 |
-
_ensure_loaded()
|
| 59 |
|
| 60 |
LOG.info("DEVICE %s", _device)
|
| 61 |
|
|
@@ -76,6 +78,8 @@ def generate_stream(message: str, history: List[Tuple[str, str]]):
|
|
| 76 |
Minimal streaming chat function for gr.ChatInterface.
|
| 77 |
Uses instruct chat template. No token UI. No extra controls.
|
| 78 |
"""
|
|
|
|
|
|
|
| 79 |
_ensure_loaded()
|
| 80 |
|
| 81 |
messages = _history_to_messages(history) + [{"role": "user", "content": message}]
|
|
|
|
| 1 |
+
# Copied/Adapted from https://huggingface.co/spaces/akhaliq/MobileLLM-Pro
|
| 2 |
+
|
| 3 |
import spaces
|
| 4 |
|
| 5 |
import logging
|
|
|
|
| 57 |
_device = next(_model.parameters()).device
|
| 58 |
|
| 59 |
|
| 60 |
+
# _ensure_loaded()
|
| 61 |
|
| 62 |
LOG.info("DEVICE %s", _device)
|
| 63 |
|
|
|
|
| 78 |
Minimal streaming chat function for gr.ChatInterface.
|
| 79 |
Uses instruct chat template. No token UI. No extra controls.
|
| 80 |
"""
|
| 81 |
+
|
| 82 |
+
# TODO: check the memory footprint doing so. We should rather do this before the spaces wrapper...
|
| 83 |
_ensure_loaded()
|
| 84 |
|
| 85 |
messages = _history_to_messages(history) + [{"role": "user", "content": message}]
|