Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,17 +5,13 @@ from llama_cpp import Llama
|
|
5 |
|
6 |
# β
Define model path
|
7 |
MODEL_PATH = "./Phi-3-mini-4k-instruct-q4.gguf"
|
8 |
-
MODEL_URL = "https://huggingface.co/
|
9 |
-
|
10 |
-
# β
Get Hugging Face API token from environment variable
|
11 |
-
HF_TOKEN = os.getenv("HF_TOKEN") # Set this securely in your Hugging Face Space
|
12 |
-
HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
|
13 |
|
14 |
# β
Check if model exists, otherwise download
|
15 |
if not os.path.exists(MODEL_PATH):
|
16 |
st.info("Downloading the model file. Please wait...")
|
17 |
try:
|
18 |
-
with requests.get(MODEL_URL,
|
19 |
response.raise_for_status() # Stops the script if download fails
|
20 |
with open(MODEL_PATH, "wb") as f:
|
21 |
for chunk in response.iter_content(chunk_size=8192):
|
@@ -67,3 +63,4 @@ if st.button("Send") and user_input:
|
|
67 |
|
68 |
|
69 |
|
|
|
|
5 |
|
6 |
# β
Define model path
|
7 |
MODEL_PATH = "./Phi-3-mini-4k-instruct-q4.gguf"
|
8 |
+
MODEL_URL = "https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf/resolve/main/Phi-3-mini-4k-instruct-q4.gguf"
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# β
Check if model exists, otherwise download
|
11 |
if not os.path.exists(MODEL_PATH):
|
12 |
st.info("Downloading the model file. Please wait...")
|
13 |
try:
|
14 |
+
with requests.get(MODEL_URL, stream=True) as response:
|
15 |
response.raise_for_status() # Stops the script if download fails
|
16 |
with open(MODEL_PATH, "wb") as f:
|
17 |
for chunk in response.iter_content(chunk_size=8192):
|
|
|
63 |
|
64 |
|
65 |
|
66 |
+
|