Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- Dockerfile +20 -0
- app.py +20 -0
- requirment.txt +10 -0
Dockerfile
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.12.6
|
2 |
+
|
3 |
+
# Set working directory inside container
|
4 |
+
WORKDIR /code
|
5 |
+
|
6 |
+
# Copy requirements file (fixing the typo in the filename and path)
|
7 |
+
COPY ./requirement.txt /code/requirement.txt
|
8 |
+
|
9 |
+
# Install dependencies
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirement.txt
|
11 |
+
|
12 |
+
# Add a non-root user and switch to it
|
13 |
+
RUN useradd -m user
|
14 |
+
USER user
|
15 |
+
|
16 |
+
# Copy the FastAPI app code
|
17 |
+
COPY . /code
|
18 |
+
|
19 |
+
# Command to run the app with uvicorn
|
20 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
|
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
|
5 |
+
app= FastAPI()
|
6 |
+
|
7 |
+
# Use a pipeline as a high-level helper
|
8 |
+
from transformers import pipeline
|
9 |
+
|
10 |
+
pipe = pipeline("text-generation", model="nvidia/Llama-3_3-Nemotron-Super-49B-v1_5", trust_remote_code=True)
|
11 |
+
|
12 |
+
@app.get("/")
|
13 |
+
def home():
|
14 |
+
return {"Message":"Hello World"}
|
15 |
+
|
16 |
+
|
17 |
+
@app.get("./generate")
|
18 |
+
def generate(text:str):
|
19 |
+
output=pipe(text)
|
20 |
+
return{"output":output[0]['generated_text']}
|
requirment.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
fastapi>=0.68.0
|
2 |
+
uvicorn>=0.15.0
|
3 |
+
transformers>=4.12.0
|
4 |
+
torch>=1.9.0
|
5 |
+
sentencepiece>=0.1.96 # Required for some models (e.g., T5, BART)
|
6 |
+
tokenizers>=0.10.0
|
7 |
+
python-multipart # For handling file uploads in FastAPI
|
8 |
+
pydantic>=1.8.0 # For data validation in FastAPI
|
9 |
+
requests>=2.26.0 # Optional, useful for making HTTP calls
|
10 |
+
numpy>=1.21.0 # Required for some model outputs
|