Spaces:
Build error
Build error
| 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 | |
| def home(): | |
| return {"message": "Your FastAPI and Model is Running"} | |
| 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']} |