Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,8 @@ from contextlib import asynccontextmanager
|
|
| 7 |
|
| 8 |
@asynccontextmanager
|
| 9 |
async def lifespan(app: FastAPI):
|
| 10 |
-
global
|
| 11 |
-
|
| 12 |
yield
|
| 13 |
|
| 14 |
app = FastAPI(lifespan=lifespan)
|
|
@@ -16,14 +16,12 @@ app = FastAPI(lifespan=lifespan)
|
|
| 16 |
class TextRequest(BaseModel):
|
| 17 |
text: str
|
| 18 |
|
| 19 |
-
@app.post("/
|
| 20 |
-
async def
|
| 21 |
try:
|
| 22 |
-
result =
|
| 23 |
-
|
| 24 |
-
"text":
|
| 25 |
-
|
| 26 |
-
"confidence": round(result['score'], 4)
|
| 27 |
-
}
|
| 28 |
except Exception as e:
|
| 29 |
return {"error": str(e)}
|
|
|
|
| 7 |
|
| 8 |
@asynccontextmanager
|
| 9 |
async def lifespan(app: FastAPI):
|
| 10 |
+
global needModel
|
| 11 |
+
needModel = pipeline("...")
|
| 12 |
yield
|
| 13 |
|
| 14 |
app = FastAPI(lifespan=lifespan)
|
|
|
|
| 16 |
class TextRequest(BaseModel):
|
| 17 |
text: str
|
| 18 |
|
| 19 |
+
@app.post("/message")
|
| 20 |
+
async def model(request: TextRequest):
|
| 21 |
try:
|
| 22 |
+
# result = needModel(request.text)[0]
|
| 23 |
+
result = {
|
| 24 |
+
"text": "hi from api!"}
|
| 25 |
+
return result
|
|
|
|
|
|
|
| 26 |
except Exception as e:
|
| 27 |
return {"error": str(e)}
|