Shazaaly commited on
Commit
273e7c2
·
1 Parent(s): 7f8eaf1

Expose classify endpoint

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -1,8 +1,6 @@
1
- # app.py
2
  from fastapi import FastAPI, HTTPException
3
  from pydantic import BaseModel
4
  from transformers import pipeline
5
- from typing import Literal
6
 
7
  app = FastAPI()
8
 
@@ -24,8 +22,8 @@ def classify_intent(req: IntentRequest):
24
  results = classifier(req.text)
25
  top = results[0]
26
  return {
27
- "label": top['label'],
28
- "confidence": top['score']
29
  }
30
  except Exception as e:
31
  raise HTTPException(status_code=500, detail=str(e))
 
 
1
  from fastapi import FastAPI, HTTPException
2
  from pydantic import BaseModel
3
  from transformers import pipeline
 
4
 
5
  app = FastAPI()
6
 
 
22
  results = classifier(req.text)
23
  top = results[0]
24
  return {
25
+ "label": top["label"],
26
+ "confidence": top["score"]
27
  }
28
  except Exception as e:
29
  raise HTTPException(status_code=500, detail=str(e))