Andrew McCracken commited on
Commit
3fad655
·
1 Parent(s): 6e61395

Fix: Install llama-cpp-python at runtime (HF Spaces workaround)

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -7
  2. main.py +7 -0
Dockerfile CHANGED
@@ -7,16 +7,10 @@ RUN apt-get update && apt-get install -y \
7
  gcc \
8
  g++ \
9
  make \
10
- wget \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy requirements and install
14
  COPY requirements.txt .
15
-
16
- # Install llama-cpp-python with pre-built wheels (much faster)
17
- RUN pip install --no-cache-dir llama-cpp-python==0.3.14 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
18
-
19
- # Install remaining requirements
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  # Copy application code
 
7
  gcc \
8
  g++ \
9
  make \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy requirements and install (llama-cpp-python installed at runtime)
13
  COPY requirements.txt .
 
 
 
 
 
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
  # Copy application code
main.py CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
  from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect, BackgroundTasks
2
  from fastapi.responses import StreamingResponse, JSONResponse, FileResponse
3
  from fastapi.middleware.cors import CORSMiddleware
 
1
+ # Install llama-cpp-python at runtime (HF Spaces workaround)
2
+ import subprocess
3
+ import sys
4
+ print("🔧 Installing llama-cpp-python at runtime...")
5
+ subprocess.run([sys.executable, "-m", "pip", "install", "-v", "llama-cpp-python==0.3.14"], check=True)
6
+ print("✅ llama-cpp-python installed successfully")
7
+
8
  from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect, BackgroundTasks
9
  from fastapi.responses import StreamingResponse, JSONResponse, FileResponse
10
  from fastapi.middleware.cors import CORSMiddleware