Spaces:
Runtime error
Runtime error
Aryan Gosaliya commited on
Commit ·
6f6fa04
1
Parent(s): 948d6ef
dockerfile
Browse files- Dockerfile +32 -0
- app/main.py +10 -7
Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Stage 1: Build the React Frontend
|
| 2 |
+
FROM node:18-slim as builder
|
| 3 |
+
WORKDIR /app/ui/claimcheck-ui
|
| 4 |
+
COPY ui/claimcheck-ui/package.json ui/claimcheck-ui/pnpm-lock.yaml ./
|
| 5 |
+
RUN npm install -g pnpm && pnpm install
|
| 6 |
+
COPY ui/claimcheck-ui/ ./
|
| 7 |
+
# Set the API base URL for the production build
|
| 8 |
+
ARG VITE_API_BASE=/
|
| 9 |
+
RUN VITE_API_BASE=${VITE_API_BASE} pnpm build
|
| 10 |
+
|
| 11 |
+
# Stage 2: Setup the Python Backend
|
| 12 |
+
FROM python:3.9-slim
|
| 13 |
+
WORKDIR /app
|
| 14 |
+
COPY requirements.txt .
|
| 15 |
+
# Install Python dependencies
|
| 16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
+
|
| 18 |
+
# Copy backend application code
|
| 19 |
+
COPY app ./app
|
| 20 |
+
COPY kb ./kb
|
| 21 |
+
COPY data ./data
|
| 22 |
+
|
| 23 |
+
# Copy the built frontend from the 'builder' stage
|
| 24 |
+
COPY --from=builder /app/ui/claimcheck-ui/dist /app/static
|
| 25 |
+
|
| 26 |
+
# Expose the port the app runs on
|
| 27 |
+
EXPOSE 7860
|
| 28 |
+
|
| 29 |
+
# Command to run the application
|
| 30 |
+
# We will serve the static files from the built UI
|
| 31 |
+
# And run the backend API with uvicorn
|
| 32 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/main.py
CHANGED
|
@@ -6,29 +6,31 @@ from fastapi import UploadFile, File
|
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
from app.core.orchestrator import process_call
|
| 8 |
from app.core.ibm_sanity import sanity_embeddings, sanity_generation
|
|
|
|
| 9 |
|
| 10 |
app = FastAPI(title="ClaimCheck")
|
|
|
|
|
|
|
| 11 |
|
| 12 |
app.add_middleware(
|
| 13 |
CORSMiddleware,
|
| 14 |
-
allow_origins=[
|
| 15 |
-
"http://localhost:5173",
|
| 16 |
-
"http://127.0.0.1:5173",
|
| 17 |
-
],
|
| 18 |
allow_credentials=True,
|
| 19 |
allow_methods=["*"],
|
| 20 |
allow_headers=["*"],
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
@app.get("/health")
|
| 24 |
def health():
|
| 25 |
return {"status": "ok", "service": "ClaimCheck"}
|
| 26 |
|
|
|
|
| 27 |
@app.get("/health/ibm")
|
| 28 |
def health_ibm():
|
| 29 |
emb = sanity_embeddings()
|
| 30 |
-
claim = sanity_generation(os.getenv("IBM_CLAIM_MODEL_ID",""), "Say OK")
|
| 31 |
-
verify = sanity_generation(os.getenv("IBM_VERIFIER_MODEL_ID",""), "Say OK")
|
| 32 |
return {"embeddings": emb, "claim_gen": claim, "verify_gen": verify}
|
| 33 |
|
| 34 |
|
|
@@ -41,9 +43,10 @@ def process_transcript(text: str = Body(..., embed=True)):
|
|
| 41 |
report = process_call(transcript=text)
|
| 42 |
return report
|
| 43 |
|
|
|
|
| 44 |
@app.post("/process-audio")
|
| 45 |
async def process_audio(file: UploadFile = File(...)):
|
| 46 |
path = f"data/audio/{file.filename}"
|
| 47 |
with open(path, "wb") as f:
|
| 48 |
f.write(await file.read())
|
| 49 |
-
return process_call(audio_path=path)
|
|
|
|
| 6 |
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
from app.core.orchestrator import process_call
|
| 8 |
from app.core.ibm_sanity import sanity_embeddings, sanity_generation
|
| 9 |
+
from fastapi.staticfiles import StaticFiles
|
| 10 |
|
| 11 |
app = FastAPI(title="ClaimCheck")
|
| 12 |
+
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 13 |
+
|
| 14 |
|
| 15 |
app.add_middleware(
|
| 16 |
CORSMiddleware,
|
| 17 |
+
allow_origins=["*"],
|
|
|
|
|
|
|
|
|
|
| 18 |
allow_credentials=True,
|
| 19 |
allow_methods=["*"],
|
| 20 |
allow_headers=["*"],
|
| 21 |
)
|
| 22 |
|
| 23 |
+
|
| 24 |
@app.get("/health")
|
| 25 |
def health():
|
| 26 |
return {"status": "ok", "service": "ClaimCheck"}
|
| 27 |
|
| 28 |
+
|
| 29 |
@app.get("/health/ibm")
|
| 30 |
def health_ibm():
|
| 31 |
emb = sanity_embeddings()
|
| 32 |
+
claim = sanity_generation(os.getenv("IBM_CLAIM_MODEL_ID", ""), "Say OK")
|
| 33 |
+
verify = sanity_generation(os.getenv("IBM_VERIFIER_MODEL_ID", ""), "Say OK")
|
| 34 |
return {"embeddings": emb, "claim_gen": claim, "verify_gen": verify}
|
| 35 |
|
| 36 |
|
|
|
|
| 43 |
report = process_call(transcript=text)
|
| 44 |
return report
|
| 45 |
|
| 46 |
+
|
| 47 |
@app.post("/process-audio")
|
| 48 |
async def process_audio(file: UploadFile = File(...)):
|
| 49 |
path = f"data/audio/{file.filename}"
|
| 50 |
with open(path, "wb") as f:
|
| 51 |
f.write(await file.read())
|
| 52 |
+
return process_call(audio_path=path)
|