Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- Dockerfile +1 -1
- main.py +5 -0
Dockerfile
CHANGED
|
@@ -22,4 +22,4 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 22 |
EXPOSE $PORT
|
| 23 |
|
| 24 |
# Command to run FastAPI with uvicorn
|
| 25 |
-
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-
|
|
|
|
| 22 |
EXPOSE $PORT
|
| 23 |
|
| 24 |
# Command to run FastAPI with uvicorn
|
| 25 |
+
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}"]
|
main.py
CHANGED
|
@@ -6,6 +6,7 @@ import faiss
|
|
| 6 |
import pickle
|
| 7 |
import redis
|
| 8 |
from fastapi import FastAPI, HTTPException
|
|
|
|
| 9 |
from pydantic import BaseModel
|
| 10 |
from sentence_transformers import SentenceTransformer
|
| 11 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
@@ -98,6 +99,10 @@ def clear_pending(session_id: str):
|
|
| 98 |
# Core endpoint
|
| 99 |
# --------------------------
|
| 100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
@app.post("/chat", response_model=ChatResponse)
|
| 102 |
def chat(req: ChatRequest):
|
| 103 |
# Check if there is a pending confirmation for this session
|
|
|
|
| 6 |
import pickle
|
| 7 |
import redis
|
| 8 |
from fastapi import FastAPI, HTTPException
|
| 9 |
+
from fastapi.responses import RedirectResponse
|
| 10 |
from pydantic import BaseModel
|
| 11 |
from sentence_transformers import SentenceTransformer
|
| 12 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
|
| 99 |
# Core endpoint
|
| 100 |
# --------------------------
|
| 101 |
|
| 102 |
+
@app.get("/", include_in_schema=False)
|
| 103 |
+
def root():
|
| 104 |
+
return RedirectResponse(url="/docs")
|
| 105 |
+
|
| 106 |
@app.post("/chat", response_model=ChatResponse)
|
| 107 |
def chat(req: ChatRequest):
|
| 108 |
# Check if there is a pending confirmation for this session
|