Spaces:
Build error
Build error
File size: 726 Bytes
9cf8b68 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from fastapi import FastAPI
from transformers import pipeline
# Creating a new FastAPI app instance
app = FastAPI()
# Calling the Hugging Face Model from the pipeline
# Here I am using the Facebook/bart-large-cnn model for summarization
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
# Creating routes
@app.get("/")
def home():
return {"message": "Your FastAPI and Model is Running"}
@app.get("/chat")
def chat(text: str):
# Use the summarizer pipeline to generate a summary from the given input text
output = summarizer(text, max_length=130, min_length=30, do_sample=False)
# Return the summary from the output
return {"summary": output[0]['summary_text']} |