IlyaGusev commited on
Commit
50a4065
1 Parent(s): a7bc44e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -7,7 +7,7 @@ import requests
7
  import time
8
  import sys
9
 
10
- from huggingface_hub import snapshot_download
11
  from llama_cpp import Llama
12
 
13
 
@@ -25,16 +25,24 @@ def get_system_tokens(model):
25
  return get_message_tokens(model, **system_message)
26
 
27
 
28
- repo_name = "IlyaGusev/saiga_mistral_7b_gguf"
 
29
  model_name = "model-q4_K.gguf"
 
30
 
31
- snapshot_download(repo_id=repo_name, local_dir=".", allow_patterns=model_name)
 
 
 
 
 
32
 
33
  model = Llama(
34
  model_path=model_name,
35
  n_ctx=2000,
36
  n_parts=1,
37
  )
 
38
 
39
  max_new_tokens = 1500
40
 
 
7
  import time
8
  import sys
9
 
10
+ from huggingface_hub.file_download import http_get
11
  from llama_cpp import Llama
12
 
13
 
 
25
  return get_message_tokens(model, **system_message)
26
 
27
 
28
+ directory = "."
29
+ model_url = "https://huggingface.co/IlyaGusev/saiga_mistral_7b_gguf/resolve/main/model-q4_K.gguf"
30
  model_name = "model-q4_K.gguf"
31
+ final_model_path = os.path.join(directory, model_name)
32
 
33
+ print("Downloading all files...")
34
+ if not os.path.exists(final_model_path):
35
+ with open(final_model_path, "wb") as f:
36
+ http_get(model_url, f)
37
+ os.chmod(final_model_path, 0o777)
38
+ print("Files downloaded!")
39
 
40
  model = Llama(
41
  model_path=model_name,
42
  n_ctx=2000,
43
  n_parts=1,
44
  )
45
+ print("Model loaded!")
46
 
47
  max_new_tokens = 1500
48