Thamaraikannan commited on
Commit
ccf12e9
·
1 Parent(s): c32002f
.gitignore CHANGED
@@ -1,4 +1,6 @@
1
  .env
2
  .venv/
3
  env/
4
- venv/
 
 
 
1
  .env
2
  .venv/
3
  env/
4
+ venv/
5
+ .__pycache__
6
+ __pycache__/
__pycache__/app.cpython-312.pyc ADDED
Binary file (1.16 kB). View file
 
__pycache__/app.cpython-39.pyc ADDED
Binary file (1.07 kB). View file
 
app.py CHANGED
@@ -4,19 +4,19 @@ from setfit import SetFitModel
4
 
5
  app = FastAPI()
6
 
 
7
  class TextInput(BaseModel):
8
  text: str
9
 
10
- class LabelScore(BaseModel):
11
- label: str
12
- score: float
13
 
14
- @app.post("/predict", response_model=LabelScore)
15
  async def predict(input: TextInput):
 
16
  model = SetFitModel.from_pretrained("assets")
17
- preds = model.predict(input)
18
- return preds
 
19
 
20
  @app.get("/")
21
  def read_root():
22
- return {"message": "Welcome to the FastAPI prediction service"}
 
4
 
5
  app = FastAPI()
6
 
7
+
8
  class TextInput(BaseModel):
9
  text: str
10
 
 
 
 
11
 
12
+ @app.post("/predict")
13
  async def predict(input: TextInput):
14
+ text_input = input.text
15
  model = SetFitModel.from_pretrained("assets")
16
+ preds = model.predict(text_input)
17
+ return {"label": preds}
18
+
19
 
20
  @app.get("/")
21
  def read_root():
22
+ return {"message": "Welcome"}