corderBackend / main.py
pius-code's picture
refactor summarize endpoint to change method back to GET and update response format
8cf2fe4
raw
history blame
531 Bytes
from fastapi import FastAPI
from pydantic import BaseModel
from transformers import pipeline
app = FastAPI()
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
class TextInput(BaseModel):
text: str
@app.get("/")
async def root():
return {"message": "Welcome to the Text Summarization API!"}
@app.get("/summarize")
async def summarize_text(input: TextInput):
summary = (summarizer(input.text, max_length=130, min_length=30, do_sample=False))
return "hello welcome to the summary end point"