kat33 commited on
Commit
2e1a289
1 Parent(s): 37c2625

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  import gradio as gr
2
  #import transformers
3
  #from transformers import pipeline
@@ -12,10 +15,17 @@ model_filename="nous-hermes-13b.ggmlv3.q4_K_S.bin"
12
 
13
  def download_model():
14
  # See https://github.com/OpenAccess-AI-Collective/ggml-webui/blob/main/tabbed.py
15
- file = hf_hub_download(
16
- repo_id=model_repo, filename=model_filename
17
- )
18
- return file
 
 
 
 
 
 
 
19
 
20
  def question_answer(context, question):
21
  mfile=download_model()
 
1
+ import os # to check if file exists
2
+ import sys # to flush stdout
3
+
4
  import gradio as gr
5
  #import transformers
6
  #from transformers import pipeline
 
15
 
16
  def download_model():
17
  # See https://github.com/OpenAccess-AI-Collective/ggml-webui/blob/main/tabbed.py
18
+ file_path=/home/user/.cache/huggingface/hub/models--TheBloke--Nous-Hermes-13B-GGML/snapshots/f1a48f90a07550e1ba30e347b2be69d4fa5e393b/nous-hermes-13b.ggmlv3.q4_K_S.bin
19
+ if os.path.exists(file_path):
20
+ return file_path
21
+ else:
22
+ print("Downloading model...")
23
+ sys.stdout.flush()
24
+ file = hf_hub_download(
25
+ repo_id=model_repo, filename=model_filename
26
+ )
27
+ print("Downloaded " + file)
28
+ return file
29
 
30
  def question_answer(context, question):
31
  mfile=download_model()