meryemka commited on
Commit
b76a59a
·
1 Parent(s): 78d7363

fixing app crash

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -1,17 +1,30 @@
1
  import subprocess
2
  import sys
3
 
4
- # Install llama-cpp-python at runtime so it builds against the current OS (glibc)
5
- subprocess.run(
6
- [sys.executable, "-m", "pip", "install", "-U", "llama-cpp-python==0.3.16", "wikipedia"],
7
- check=True,
8
- )
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  import gradio as gr
 
11
  from agent import respond, build_prompt
12
  from llama_cpp import Llama
13
  import random
14
- import wikipedia
15
  # ---------------- CONFIG ----------------
16
  BASE_REPO_ID = "unsloth/Llama-3.2-3B-Instruct-GGUF"
17
  BASE_FILENAME = "Llama-3.2-3B-Instruct-Q4_K_M.gguf"
 
1
  import subprocess
2
  import sys
3
 
4
+ print("--- STARTING INSTALLATION ---")
5
+ try:
6
+ # 1. Install llama-cpp-python
7
+ subprocess.run(
8
+ [sys.executable, "-m", "pip", "install", "-U", "llama-cpp-python==0.3.16"],
9
+ check=True,
10
+ )
11
+
12
+ # 2. Install wikipedia (Second command - FORCES install)
13
+ print("--- INSTALLING WIKIPEDIA ---")
14
+ subprocess.run(
15
+ [sys.executable, "-m", "pip", "install", "wikipedia"],
16
+ check=True,
17
+ )
18
+ print("--- WIKIPEDIA INSTALLED ---")
19
+ except Exception as e:
20
+ print(f"--- INSTALLATION FAILED: {e} ---")
21
 
22
  import gradio as gr
23
+ import wikipedia # This will now work
24
  from agent import respond, build_prompt
25
  from llama_cpp import Llama
26
  import random
27
+
28
  # ---------------- CONFIG ----------------
29
  BASE_REPO_ID = "unsloth/Llama-3.2-3B-Instruct-GGUF"
30
  BASE_FILENAME = "Llama-3.2-3B-Instruct-Q4_K_M.gguf"