Spaces:
Runtime error
Runtime error
Commit
·
c379e3b
1
Parent(s):
c2d5a85
updated requirements.txt file
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("text-generation", model="microsoft/phi-4", trust_remote_code=True)
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
|
10 |
+
@app.get('/')
|
11 |
+
def home():
|
12 |
+
return {"hello": "Geominds"}
|
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[standard]
|
2 |
+
uvicorn
|
3 |
+
transformers
|
4 |
+
torch
|
5 |
+
torchvision
|