LucasAguetai commited on
Commit
b4d0d8e
1 Parent(s): ac14130
Files changed (2) hide show
  1. app.py +8 -0
  2. modeles.py +5 -0
app.py CHANGED
@@ -6,6 +6,7 @@ from fastapi import FastAPI, UploadFile, File
6
  from typing import Union
7
  import json
8
  import csv
 
9
 
10
 
11
  app = FastAPI()
@@ -46,6 +47,13 @@ async def create_upload_file(texte: str, model: str):
46
 
47
  return {"model": model, "texte": texte}
48
 
 
 
 
 
 
 
 
49
 
50
  def extract_data(file: UploadFile) -> Union[str, dict, list]:
51
  if file.filename.endswith(".txt"):
 
6
  from typing import Union
7
  import json
8
  import csv
9
+ from modeles import bert
10
 
11
 
12
  app = FastAPI()
 
47
 
48
  return {"model": model, "texte": texte}
49
 
50
+ @app.post("/bert/")
51
+ async def qabert(context: str, question: str):
52
+ bertAnswer = bert(context, question)
53
+ if bert:
54
+ return bert
55
+ else:
56
+ raise HTTPException(status_code=400, detail="Error")
57
 
58
  def extract_data(file: UploadFile) -> Union[str, dict, list]:
59
  if file.filename.endswith(".txt"):
modeles.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ def bert(context, question):
4
+ question_answerer = pipeline("question-answering", "alexandre-huynh/bert-base-uncased-finetuned-squad-single-epoch", framework="tf")
5
+ return(question_answerer(context=context, question=question))