FM-1976 commited on
Commit
112cd69
·
verified ·
1 Parent(s): 2762745

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -7,6 +7,7 @@ import random
7
  import string
8
  from time import sleep
9
  import tiktoken
 
10
 
11
  # for counting the tokens in the prompt and in the result
12
  #context_count = len(encoding.encode(yourtext))
@@ -30,6 +31,15 @@ if "messages" not in st.session_state:
30
  if "repeat" not in st.session_state:
31
  st.session_state.repeat = 1.35
32
 
 
 
 
 
 
 
 
 
 
33
  if "temperature" not in st.session_state:
34
  st.session_state.temperature = 0.1
35
 
@@ -64,9 +74,8 @@ def genRANstring(n):
64
  def create_chat():
65
  # Set HF API token and HF repo
66
  from llama_cpp import Llama
67
- client = Llama.from_pretrained(
68
- repo_id="bartowski/gemma-2-2b-it-GGUF",
69
- filename="gemma-2-2b-it-Q5_K_M.gguf",
70
  temperature=0.24,
71
  n_ctx=nCTX,
72
  max_tokens=600,
 
7
  import string
8
  from time import sleep
9
  import tiktoken
10
+ from huggingface_hub import hf_hub_download
11
 
12
  # for counting the tokens in the prompt and in the result
13
  #context_count = len(encoding.encode(yourtext))
 
31
  if "repeat" not in st.session_state:
32
  st.session_state.repeat = 1.35
33
 
34
+
35
+
36
+ if "modelfile" not in st.session_state:
37
+ modelfile = hf_hub_download(
38
+ repo_id=os.environ.get("REPO_ID", "bartowski/gemma-2-2b-it-GGUF"),
39
+ filename=os.environ.get("MODEL_FILE", "gemma-2-2b-it-Q5_K_M.gguf"),
40
+ )
41
+ st.session_state.modelfile = modelfile
42
+
43
  if "temperature" not in st.session_state:
44
  st.session_state.temperature = 0.1
45
 
 
74
  def create_chat():
75
  # Set HF API token and HF repo
76
  from llama_cpp import Llama
77
+ client = Llama(
78
+ model_path=st.session_state.modelfile,
 
79
  temperature=0.24,
80
  n_ctx=nCTX,
81
  max_tokens=600,