Spaces:
Runtime error
Runtime error
Commit
·
5a0088c
1
Parent(s):
42712ac
push test
Browse files- Dockerfile +14 -0
- app.py +18 -0
- requirements.txt +5 -0
Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
RUN useradd user
|
| 4 |
+
USER user
|
| 5 |
+
ENV HOME=/home/user \
|
| 6 |
+
PATH=/home/user/.local/bin:$PATH
|
| 7 |
+
|
| 8 |
+
WORKDIR $HOME/app
|
| 9 |
+
|
| 10 |
+
COPY --chown=user ./ $HOME/app
|
| 11 |
+
|
| 12 |
+
RUN pip install -r requirements.txt
|
| 13 |
+
|
| 14 |
+
CMD fastapi run --reload --host=0.0.0.0 --port=7860
|
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
# Use a pipeline as a high-level helper
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
pipe = pipeline("text2text-generation", model="google/flan-t5-base")
|
| 6 |
+
|
| 7 |
+
app = FastAPI()
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@app.get('/')
|
| 11 |
+
def home():
|
| 12 |
+
return {"hello": "Bitfumes"}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@app.get('/ask')
|
| 16 |
+
def ask(prompt: str):
|
| 17 |
+
result = pipe(prompt)
|
| 18 |
+
return result[0]
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn
|
| 3 |
+
transformers
|
| 4 |
+
torch
|
| 5 |
+
torchvision
|