SebaK13 commited on
Commit
aca9b7c
1 Parent(s): a6c83a1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -16
app.py CHANGED
@@ -1,25 +1,13 @@
1
  from fastapi import FastAPI
2
- from transformers import pipeline
 
3
 
4
  # Create a new FastAPI app instance
5
  app = FastAPI()
6
-
7
- # Initialize the text classification pipeline
8
- # This function will be able to classify text
9
- # given an input.
10
- model_path = "SebaK13/DistilBERT-finetuned-customer-queries-balanced"
11
- pipe = pipeline("text-classification", model=model_path)
12
 
 
13
 
14
  @app.get("/")
15
  def greet_json():
16
  return {"detail": "AI Challenge FastAPI"}
17
-
18
- # Define a function to handle the GET request at `/predict`
19
- # The predict() function is defined as a FastAPI route that takes a
20
- # string parameter called query. The function returns label based on the # input using the pipeline() object, and returns a JSON response
21
- # containing the predicted label under the key "label"
22
- @app.get("/predict")
23
- def predict(query: str):
24
- output = pipe(query)
25
- return {"label": output[0]["generated_text"]}
 
1
  from fastapi import FastAPI
2
+
3
+ from routers import distilbert
4
 
5
  # Create a new FastAPI app instance
6
  app = FastAPI()
 
 
 
 
 
 
7
 
8
+ app.include_router(distilbert)
9
 
10
  @app.get("/")
11
  def greet_json():
12
  return {"detail": "AI Challenge FastAPI"}
13
+