Spaces:
Sleeping
Sleeping
rehaan commited on
Commit ·
fe059fc
1
Parent(s): efdbede
Update Dockerfile and requirements.txt; refactor NivraRAGRetriever import handling
Browse files- Dockerfile +4 -16
- nivra_agent.py +11 -3
- requirements.txt +2 -9
Dockerfile
CHANGED
|
@@ -1,31 +1,19 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
-
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
# Environment sanity
|
| 7 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 8 |
ENV PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# Install system dependencies
|
| 11 |
-
RUN apt-get update && apt-get install -y \
|
| 12 |
-
build-essential \
|
| 13 |
-
git \
|
| 14 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
-
|
| 16 |
-
# Copy requirements first (better caching)
|
| 17 |
COPY requirements.txt .
|
| 18 |
|
| 19 |
-
# Install Python dependencies
|
| 20 |
RUN pip install --no-cache-dir --upgrade pip \
|
| 21 |
&& pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
| 23 |
-
# Copy application code
|
| 24 |
COPY . .
|
| 25 |
|
| 26 |
-
# HF Spaces port
|
| 27 |
EXPOSE 7860
|
| 28 |
|
| 29 |
-
|
| 30 |
-
CMD ["uvicorn", "backend.api_backend:app", "--host", "0.0.0.0", "--port", "7860", "--root-path", "/proxy/7860"]
|
| 31 |
-
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 5 |
ENV PYTHONDONTWRITEBYTECODE=1
|
| 6 |
ENV PYTHONUNBUFFERED=1
|
| 7 |
+
ENV GRADIO_SERVER_NAME=0.0.0.0
|
| 8 |
+
ENV GRADIO_SERVER_PORT=7860
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
COPY requirements.txt .
|
| 11 |
|
|
|
|
| 12 |
RUN pip install --no-cache-dir --upgrade pip \
|
| 13 |
&& pip install --no-cache-dir -r requirements.txt
|
| 14 |
|
|
|
|
| 15 |
COPY . .
|
| 16 |
|
|
|
|
| 17 |
EXPOSE 7860
|
| 18 |
|
| 19 |
+
CMD ["python", "app.py"]
|
|
|
|
|
|
nivra_agent.py
CHANGED
|
@@ -9,7 +9,6 @@ import json
|
|
| 9 |
from datetime import datetime
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
|
| 12 |
-
from agent.rag_retriever import NivraRAGRetriever
|
| 13 |
from agent.text_symptom_tool import analyze_symptom_text
|
| 14 |
from agent.image_symptom_tool import analyze_symptom_image
|
| 15 |
|
|
@@ -46,7 +45,12 @@ _rag = None
|
|
| 46 |
def get_rag():
|
| 47 |
global _rag
|
| 48 |
if _rag is None:
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
return _rag
|
| 51 |
|
| 52 |
# ==================================================
|
|
@@ -241,7 +245,11 @@ def nivra_chat(user_input, chat_history=None):
|
|
| 241 |
|
| 242 |
try:
|
| 243 |
tool_results.append(analyze_symptom_text.invoke(user_input))
|
| 244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
except Exception:
|
| 246 |
tool_results.append("TOOL FAILURE")
|
| 247 |
|
|
|
|
| 9 |
from datetime import datetime
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
|
|
|
|
| 12 |
from agent.text_symptom_tool import analyze_symptom_text
|
| 13 |
from agent.image_symptom_tool import analyze_symptom_image
|
| 14 |
|
|
|
|
| 45 |
def get_rag():
|
| 46 |
global _rag
|
| 47 |
if _rag is None:
|
| 48 |
+
try:
|
| 49 |
+
from agent.rag_retriever import NivraRAGRetriever
|
| 50 |
+
|
| 51 |
+
_rag = NivraRAGRetriever()
|
| 52 |
+
except Exception:
|
| 53 |
+
_rag = False
|
| 54 |
return _rag
|
| 55 |
|
| 56 |
# ==================================================
|
|
|
|
| 245 |
|
| 246 |
try:
|
| 247 |
tool_results.append(analyze_symptom_text.invoke(user_input))
|
| 248 |
+
rag = get_rag()
|
| 249 |
+
if rag:
|
| 250 |
+
tool_results.append(rag.getRelevantDocs(user_input))
|
| 251 |
+
else:
|
| 252 |
+
tool_results.append("RAG UNAVAILABLE")
|
| 253 |
except Exception:
|
| 254 |
tool_results.append("TOOL FAILURE")
|
| 255 |
|
requirements.txt
CHANGED
|
@@ -6,18 +6,11 @@ python-multipart
|
|
| 6 |
|
| 7 |
# Networking
|
| 8 |
httpx
|
|
|
|
| 9 |
|
| 10 |
-
#
|
| 11 |
langchain
|
| 12 |
langchain-core
|
| 13 |
langchain-community
|
| 14 |
langchain-groq
|
| 15 |
-
langchain-huggingface
|
| 16 |
-
langchain-chroma # ← THIS WAS MISSING
|
| 17 |
-
|
| 18 |
-
# Groq SDK
|
| 19 |
groq
|
| 20 |
-
|
| 21 |
-
# Vector DB / embeddings
|
| 22 |
-
chromadb
|
| 23 |
-
sentence-transformers
|
|
|
|
| 6 |
|
| 7 |
# Networking
|
| 8 |
httpx
|
| 9 |
+
requests
|
| 10 |
|
| 11 |
+
# Agent runtime
|
| 12 |
langchain
|
| 13 |
langchain-core
|
| 14 |
langchain-community
|
| 15 |
langchain-groq
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
groq
|
|
|
|
|
|
|
|
|
|
|
|