File size: 473 Bytes
d24bd61
eb90c52
 
 
 
 
 
 
 
 
 
 
6915dbd
 
 
d24bd61
 
 
eb90c52
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from fastapi import FastAPI
from pydantic import BaseModel
from typing import Optional
from transformers import pipeline

app = FastAPI()
summarizer = pipeline("summarization", model="Falconsai/text_summarization")


class InputText(BaseModel):
    text: str


app = FastAPI()

@app.get("/")
def greet_json():
    return {"Hello": "World!"}


@app.get("/summary")
def summary(inp: InputText):
    return summarizer(inp.text, max_length=1000, min_length=30, do_sample=False)