paarthmadan commited on
Commit
8144c07
·
1 Parent(s): 9f5c4bb

Delete sentiment_analyzer/api.py

Browse files
Files changed (1) hide show
  1. sentiment_analyzer/api.py +0 -30
sentiment_analyzer/api.py DELETED
@@ -1,30 +0,0 @@
1
- from typing import Dict
2
-
3
- from fastapi import Depends, FastAPI
4
- from pydantic import BaseModel
5
-
6
- from .classifier.model import Model, get_model
7
-
8
- app = FastAPI()
9
-
10
-
11
- class SentimentRequest(BaseModel):
12
- text: str
13
-
14
- class SentimentResponse(BaseModel):
15
- probabilities: Dict[str, float]
16
- sentiment: str
17
- confidence: float
18
-
19
-
20
- @app.post("/predict", response_model=SentimentResponse)
21
- def predict(request: SentimentRequest, model: Model = Depends(get_model)):
22
- sentiment, confidence, probabilities = model.predict(request.text)
23
- return SentimentResponse(
24
- sentiment=sentiment, confidence=confidence, probabilities=probabilities
25
- )
26
-
27
-
28
- @app.get("/")
29
- def read_root():
30
- return {"TrueFoundry": "Project"}