ffreemt
commited on
Commit
·
d89e980
1
Parent(s):
fd0376c
Update wget aria2 in packages.txt
Browse files- app.py +11 -2
- packages.txt +1 -0
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import os
|
|
@@ -15,6 +17,9 @@ from huggingface_hub import hf_hub_download, hf_hub_url # snapshot_download,
|
|
| 15 |
from loguru import logger
|
| 16 |
from python_run_cmd import run_cmd
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
os.environ["TZ"] = "Asia/Shanghai"
|
| 19 |
try:
|
| 20 |
time.tzset() # type: ignore
|
|
@@ -28,7 +33,9 @@ filename = "openbuddy-mistral-7b-v13.Q4_K_M.gguf" # 4.39G
|
|
| 28 |
|
| 29 |
model_ready = True
|
| 30 |
logger.debug("Start dl")
|
|
|
|
| 31 |
# try to download 5 times:
|
|
|
|
| 32 |
for idx in range(5):
|
| 33 |
logger.debug(f"attempt {idx + 1}")
|
| 34 |
try:
|
|
@@ -53,7 +60,7 @@ if not model_ready: # try aria2c
|
|
| 53 |
url = hf_hub_url(
|
| 54 |
repo_id,
|
| 55 |
filename,
|
| 56 |
-
# revision="
|
| 57 |
)
|
| 58 |
logger.debug(f"{url=}")
|
| 59 |
ret = run_cmd(f"wget -c {url}", mute_stdout=False)
|
|
@@ -62,7 +69,7 @@ if not model_ready: # try aria2c
|
|
| 62 |
model_path = f"./{filename}"
|
| 63 |
|
| 64 |
# both successful
|
| 65 |
-
if not ret.returncode
|
| 66 |
model_ready = True
|
| 67 |
|
| 68 |
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
|
@@ -138,6 +145,8 @@ css = ".generating {visibility: hidden}"
|
|
| 138 |
|
| 139 |
# Based on the gradio theming guide and borrowed from https://huggingface.co/spaces/shivi/dolly-v2-demo
|
| 140 |
class SeafoamCustom(Base):
|
|
|
|
|
|
|
| 141 |
def __init__(
|
| 142 |
self,
|
| 143 |
*,
|
|
|
|
| 1 |
+
"""Run."""
|
| 2 |
+
# pylint: disable=invalid-name,line-too-long,broad-except,missing-function-docstring
|
| 3 |
from __future__ import annotations
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 17 |
from loguru import logger
|
| 18 |
from python_run_cmd import run_cmd
|
| 19 |
|
| 20 |
+
ret = run_cmd("which aria2c", mute_stdout=False)
|
| 21 |
+
logger.debug(ret)
|
| 22 |
+
|
| 23 |
os.environ["TZ"] = "Asia/Shanghai"
|
| 24 |
try:
|
| 25 |
time.tzset() # type: ignore
|
|
|
|
| 33 |
|
| 34 |
model_ready = True
|
| 35 |
logger.debug("Start dl")
|
| 36 |
+
|
| 37 |
# try to download 5 times:
|
| 38 |
+
model_path = f"./{filename}"
|
| 39 |
for idx in range(5):
|
| 40 |
logger.debug(f"attempt {idx + 1}")
|
| 41 |
try:
|
|
|
|
| 60 |
url = hf_hub_url(
|
| 61 |
repo_id,
|
| 62 |
filename,
|
| 63 |
+
# revision="main",
|
| 64 |
)
|
| 65 |
logger.debug(f"{url=}")
|
| 66 |
ret = run_cmd(f"wget -c {url}", mute_stdout=False)
|
|
|
|
| 69 |
model_path = f"./{filename}"
|
| 70 |
|
| 71 |
# both successful
|
| 72 |
+
if not ret.returncode:
|
| 73 |
model_ready = True
|
| 74 |
|
| 75 |
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
|
|
|
| 145 |
|
| 146 |
# Based on the gradio theming guide and borrowed from https://huggingface.co/spaces/shivi/dolly-v2-demo
|
| 147 |
class SeafoamCustom(Base):
|
| 148 |
+
"""Define."""
|
| 149 |
+
|
| 150 |
def __init__(
|
| 151 |
self,
|
| 152 |
*,
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
aria2
|