Spaces:
Build error
Build error
retry on failed hub fetch
Browse files
chat.py
CHANGED
@@ -1,16 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
import yaml
|
3 |
from huggingface_hub import hf_hub_download
|
|
|
4 |
from llama_cpp import Llama
|
5 |
|
6 |
with open("./config.yml", "r") as f:
|
7 |
config = yaml.load(f, Loader=yaml.Loader)
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
llm = Llama(model_path=fp, **config["llama_cpp"])
|
13 |
|
|
|
14 |
def chat(inp, history, system_message):
|
15 |
history = history or []
|
16 |
history.append((inp, ""))
|
|
|
1 |
import gradio as gr
|
2 |
import yaml
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
+
from huggingface_hub.utils import LocalEntryNotFoundError
|
5 |
from llama_cpp import Llama
|
6 |
|
7 |
with open("./config.yml", "r") as f:
|
8 |
config = yaml.load(f, Loader=yaml.Loader)
|
9 |
+
while True:
|
10 |
+
try:
|
11 |
+
fp = hf_hub_download(
|
12 |
+
repo_id=config["repo"], filename=config["file"],
|
13 |
+
)
|
14 |
+
break
|
15 |
+
except LocalEntryNotFoundError as e:
|
16 |
+
if "Connection error" in str(e):
|
17 |
+
print(str(e) + ", retrying...")
|
18 |
+
else:
|
19 |
+
raise(e)
|
20 |
|
21 |
llm = Llama(model_path=fp, **config["llama_cpp"])
|
22 |
|
23 |
+
|
24 |
def chat(inp, history, system_message):
|
25 |
history = history or []
|
26 |
history.append((inp, ""))
|