Kalpokoch commited on
Commit
0a6902c
·
2 Parent(s): 3c5eae8 5d76e26
Files changed (3) hide show
  1. Dockerfile +14 -10
  2. app/app.py +4 -0
  3. requirements.txt +0 -1
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- # Use official Python image
2
- FROM python:3.10
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
@@ -14,22 +14,26 @@ RUN apt-get update && apt-get install -y \
14
  # Set working directory
15
  WORKDIR /app
16
 
 
 
 
 
 
 
 
17
  # Copy all project files
18
  COPY . .
19
 
20
- # Download and install llama-cpp-python prebuilt wheel from Hugging Face Dataset
21
- RUN wget https://huggingface.co/datasets/Kalpokoch/wheel-llama/resolve/main/llama_cpp_python-0.3.13-cp311-cp311-linux_x86_64.whl -O llama_cpp_python.whl && \
22
- pip install llama_cpp_python.whl && \
23
- rm llama_cpp_python.whl
24
 
25
  # Install remaining Python dependencies
26
  RUN pip install --no-cache-dir -r requirements.txt
27
 
28
- # Ensure /app/models exists and is writable
29
- RUN mkdir -p /app/models && chmod -R 777 /app/models
30
-
31
  # Expose FastAPI port
32
  EXPOSE 7860
33
 
34
- # Run the FastAPI app
35
  CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use official Python 3.11 image to match the wheel compatibility
2
+ FROM python:3.11
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
 
14
  # Set working directory
15
  WORKDIR /app
16
 
17
+ # Set Hugging Face and Transformers cache to avoid permission errors
18
+ ENV TRANSFORMERS_CACHE=/app/.cache \
19
+ HF_HOME=/app/.cache
20
+
21
+ # Create and give full access to cache and model folders
22
+ RUN mkdir -p /app/.cache /app/models && chmod -R 777 /app/.cache /app/models
23
+
24
  # Copy all project files
25
  COPY . .
26
 
27
+ # Download and install llama-cpp-python wheel from Hugging Face Dataset
28
+ RUN wget https://huggingface.co/datasets/Kalpokoch/wheel-llama/resolve/main/llama_cpp_python-0.3.13-cp311-cp311-linux_x86_64.whl && \
29
+ pip install llama_cpp_python-0.3.13-cp311-cp311-linux_x86_64.whl && \
30
+ rm llama_cpp_python-0.3.13-cp311-cp311-linux_x86_64.whl
31
 
32
  # Install remaining Python dependencies
33
  RUN pip install --no-cache-dir -r requirements.txt
34
 
 
 
 
35
  # Expose FastAPI port
36
  EXPOSE 7860
37
 
38
+ # Start FastAPI app
39
  CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]
app/app.py CHANGED
@@ -48,6 +48,10 @@ app.add_middleware(
48
  allow_headers=["*"],
49
  )
50
 
 
 
 
 
51
  class ChatRequest(BaseModel):
52
  question: str
53
 
 
48
  allow_headers=["*"],
49
  )
50
 
51
+ @app.get("/")
52
+ def read_root():
53
+ return {"message": "RAG chatbot backend is running!"}
54
+
55
  class ChatRequest(BaseModel):
56
  question: str
57
 
requirements.txt CHANGED
@@ -1,6 +1,5 @@
1
  fastapi
2
  uvicorn
3
  huggingface_hub
4
- llama-cpp-python
5
  sentence-transformers
6
  scikit-learn
 
1
  fastapi
2
  uvicorn
3
  huggingface_hub
 
4
  sentence-transformers
5
  scikit-learn