Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- Dockerfile +0 -6
- app.py +9 -6
Dockerfile
CHANGED
@@ -19,12 +19,6 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
19 |
COPY app.py .
|
20 |
COPY model.py .
|
21 |
|
22 |
-
# Create and copy static files
|
23 |
-
RUN mkdir -p static
|
24 |
-
RUN if [ -d "static" ] && [ "$(ls -A static)" ]; then \
|
25 |
-
cp -r static/* ./static/; \
|
26 |
-
fi
|
27 |
-
|
28 |
# Copy dataset if it exists, otherwise create a placeholder
|
29 |
COPY dataset.txt* ./
|
30 |
|
|
|
19 |
COPY app.py .
|
20 |
COPY model.py .
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Copy dataset if it exists, otherwise create a placeholder
|
23 |
COPY dataset.txt* ./
|
24 |
|
app.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
from fastapi import FastAPI, HTTPException
|
2 |
-
from fastapi.staticfiles import StaticFiles
|
3 |
-
from fastapi.responses import FileResponse
|
4 |
from pydantic import BaseModel
|
5 |
import torch
|
6 |
import torch.nn as nn
|
@@ -10,9 +8,6 @@ import json
|
|
10 |
|
11 |
app = FastAPI(title="Poetry Generator", description="AI Poetry Generator using GPT model")
|
12 |
|
13 |
-
# Mount static files
|
14 |
-
app.mount("/static", StaticFiles(directory="static"), name="static")
|
15 |
-
|
16 |
# Load model configuration and vocabulary
|
17 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
18 |
|
@@ -179,7 +174,15 @@ class PoetryResponse(BaseModel):
|
|
179 |
|
180 |
@app.get("/")
|
181 |
async def root():
|
182 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
@app.get("/api")
|
185 |
async def api_info():
|
|
|
1 |
from fastapi import FastAPI, HTTPException
|
|
|
|
|
2 |
from pydantic import BaseModel
|
3 |
import torch
|
4 |
import torch.nn as nn
|
|
|
8 |
|
9 |
app = FastAPI(title="Poetry Generator", description="AI Poetry Generator using GPT model")
|
10 |
|
|
|
|
|
|
|
11 |
# Load model configuration and vocabulary
|
12 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
13 |
|
|
|
174 |
|
175 |
@app.get("/")
|
176 |
async def root():
|
177 |
+
return {
|
178 |
+
"message": "Welcome to Poetry Generator API",
|
179 |
+
"endpoints": {
|
180 |
+
"/api": "GET - API information",
|
181 |
+
"/health": "GET - Health check",
|
182 |
+
"/generate": "POST - Generate poetry",
|
183 |
+
"/generate_creative": "POST - Generate creative poetry"
|
184 |
+
}
|
185 |
+
}
|
186 |
|
187 |
@app.get("/api")
|
188 |
async def api_info():
|