Jasmine Wong commited on
Commit
c1ae10f
·
1 Parent(s): e5e9b2e

full stack HF deployment

Browse files
Files changed (3) hide show
  1. Dockerfile +22 -5
  2. app.py +52 -3
  3. requirements.txt +4 -2
Dockerfile CHANGED
@@ -1,7 +1,24 @@
1
- FROM node:20-slim
 
 
 
 
 
2
  WORKDIR /app
3
- COPY dist/client ./public
4
- COPY server.js .
5
- RUN npm install express
 
 
 
 
 
 
 
 
 
 
 
6
  EXPOSE 7860
7
- CMD ["node", "server.js"]
 
 
1
+ FROM python:3.11-slim
2
+
3
+ RUN apt-get update && apt-get install -y curl nodejs npm && \
4
+ npm install -g bun && \
5
+ rm -rf /var/lib/apt/lists/*
6
+
7
  WORKDIR /app
8
+
9
+ # Install Python deps
10
+ COPY requirements.txt .
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Copy everything
14
+ COPY . .
15
+
16
+ # Build frontend
17
+ RUN bun install && bun run build
18
+
19
+ # Install static file server
20
+ RUN pip install aiofiles
21
+
22
  EXPOSE 7860
23
+
24
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,7 +1,56 @@
 
 
1
  from fastapi import FastAPI
 
 
 
 
 
2
 
3
  app = FastAPI()
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import os
3
  from fastapi import FastAPI
4
+ from fastapi.staticfiles import StaticFiles
5
+ from fastapi.responses import FileResponse
6
+ from fastapi.middleware.cors import CORSMiddleware
7
+ from pydantic import BaseModel
8
+ import httpx
9
 
10
  app = FastAPI()
11
 
12
+ app.add_middleware(
13
+ CORSMiddleware,
14
+ allow_origins=["*"],
15
+ allow_methods=["*"],
16
+ allow_headers=["*"],
17
+ )
18
+
19
+ AMD_BACKEND = os.getenv("AI_BASE_URL", "http://165.245.137.74:8006")
20
+
21
+ class Query(BaseModel):
22
+ input: str
23
+
24
+ @app.post("/triage")
25
+ async def triage(query: Query):
26
+ async with httpx.AsyncClient(timeout=300) as client:
27
+ resp = await client.post(f"{AMD_BACKEND}/triage", json={"input": query.input})
28
+ return resp.json()
29
+
30
+ @app.post("/branch-debug")
31
+ async def branch_debug(query: Query):
32
+ async with httpx.AsyncClient(timeout=300) as client:
33
+ resp = await client.post(f"{AMD_BACKEND}/branch-debug", json={"input": query.input})
34
+ return resp.json()
35
+
36
+ @app.post("/forensic")
37
+ async def forensic(query: Query):
38
+ async with httpx.AsyncClient(timeout=300) as client:
39
+ resp = await client.post(f"{AMD_BACKEND}/forensic", json={"input": query.input})
40
+ return resp.json()
41
+
42
+ @app.post("/v1/chat/completions")
43
+ async def chat_completions(request: dict):
44
+ async with httpx.AsyncClient(timeout=300) as client:
45
+ resp = await client.post(f"{AMD_BACKEND}/v1/chat/completions", json=request)
46
+ return resp.json()
47
+
48
+ @app.get("/health")
49
+ async def health():
50
+ return {"status": "ok", "backend": AMD_BACKEND}
51
+
52
+ app.mount("/", StaticFiles(directory="dist/client", html=True), name="static")
53
+
54
+ if __name__ == "__main__":
55
+ import uvicorn
56
+ uvicorn.run(app, host="0.0.0.0", port=7860)
requirements.txt CHANGED
@@ -1,5 +1,7 @@
1
  fastapi
2
  uvicorn
3
- pydantic
 
4
  langchain
5
- langchain-ollama
 
 
1
  fastapi
2
  uvicorn
3
+ httpx
4
+ aiofiles
5
  langchain
6
+ langchain-ollama
7
+ langchain-community