Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ from starlette.middleware.cors import CORSMiddleware
|
|
| 4 |
from pydantic import BaseModel
|
| 5 |
import uvicorn
|
| 6 |
import torch
|
|
|
|
|
|
|
| 7 |
from simpletransformers.classification import ClassificationModel
|
| 8 |
app = FastAPI()
|
| 9 |
|
|
@@ -27,8 +29,10 @@ async def c(query:Query):
|
|
| 27 |
try:
|
| 28 |
predictions, raw_outputs = rob_chem_model.predict([str(query.query)])
|
| 29 |
print(predictions)
|
| 30 |
-
|
| 31 |
-
return
|
|
|
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
except Exception as e:
|
|
|
|
| 4 |
from pydantic import BaseModel
|
| 5 |
import uvicorn
|
| 6 |
import torch
|
| 7 |
+
from fastapi.encoders import jsonable_encoder
|
| 8 |
+
from fastapi.responses import JSONResponse
|
| 9 |
from simpletransformers.classification import ClassificationModel
|
| 10 |
app = FastAPI()
|
| 11 |
|
|
|
|
| 29 |
try:
|
| 30 |
predictions, raw_outputs = rob_chem_model.predict([str(query.query)])
|
| 31 |
print(predictions)
|
| 32 |
+
json_compatible_item_data = jsonable_encoder(predictions[0])
|
| 33 |
+
return JSONResponse(content=json_compatible_item_data)
|
| 34 |
+
#answer = {"prediction":predictions[0]}
|
| 35 |
+
#return answer
|
| 36 |
|
| 37 |
|
| 38 |
except Exception as e:
|