ffreemt commited on
Commit
d93bf74
1 Parent(s): 4594bdc
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,5 +1,7 @@
1
  from __future__ import annotations
2
 
 
 
3
  from typing import Iterable
4
 
5
  import gradio as gr
@@ -12,11 +14,22 @@ from gradio.themes.utils import colors, fonts, sizes
12
  from huggingface_hub import hf_hub_download # snapshot_download,
13
  from loguru import logger
14
 
 
 
 
 
 
 
 
15
  repo_id = "TheBloke/openbuddy-mistral-7B-v13-GGUF"
16
  filename = "openbuddy-mistral-7b-v13.Q4_K_S.gguf" # 4.17G
17
 
18
  logger.debug("Start dl")
19
- model_path = hf_hub_download(repo_id=repo_id, filename=filename, revision="main")
 
 
 
 
20
  logger.debug("Done dl")
21
 
22
  # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
@@ -27,7 +40,7 @@ try:
27
  pynvml.nvmlInit()
28
  has_cuda = True
29
  logger.debug("has cuda")
30
- except pynvml.nvml.NVMLError_LibraryNotFound:
31
  logger.debug("no cuda")
32
 
33
  # if torch.cuda.is_available():
@@ -72,6 +85,7 @@ examples = ["Hello!"]
72
 
73
 
74
  def process_example(args):
 
75
  for x in response(args):
76
  pass
77
  return x
 
1
  from __future__ import annotations
2
 
3
+ import os
4
+ import time
5
  from typing import Iterable
6
 
7
  import gradio as gr
 
14
  from huggingface_hub import hf_hub_download # snapshot_download,
15
  from loguru import logger
16
 
17
+ os.environ["TZ"] = "Asia/Shanghai"
18
+ try:
19
+ time.tzset() # type: ignore
20
+ logger.debug(f"Timezone set to {os.environ['TZ']=}")
21
+ except AttributeError:
22
+ ... # Windows
23
+
24
  repo_id = "TheBloke/openbuddy-mistral-7B-v13-GGUF"
25
  filename = "openbuddy-mistral-7b-v13.Q4_K_S.gguf" # 4.17G
26
 
27
  logger.debug("Start dl")
28
+ try:
29
+ model_path = hf_hub_download(repo_id=repo_id, filename=filename, revision="main")
30
+ except Exception as exc:
31
+ logger.error(exc)
32
+ raise SystemExit("hf acting up, can't donwload the model, exiting")
33
  logger.debug("Done dl")
34
 
35
  # Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
 
40
  pynvml.nvmlInit()
41
  has_cuda = True
42
  logger.debug("has cuda")
43
+ except pynvml.nvml.NVMLError_LibraryNotFound: # type: ignore
44
  logger.debug("no cuda")
45
 
46
  # if torch.cuda.is_available():
 
85
 
86
 
87
  def process_example(args):
88
+ x = None
89
  for x in response(args):
90
  pass
91
  return x