File size: 487 Bytes
7f237e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastapi import FastAPI
from huggingface_hub import InferenceClient
import os

app = FastAPI()

client = InferenceClient(
    model="VoltIC/Automated-Text-Summarizer", 
    token=os.getenv("HF_TOKEN")
)

@app.get("/")
def home():
    return {"message": "Summarizer API is running!"}

@app.post("/summarize")
def summarize(text: str):
    try:
        summary = client.summarization(text)
        return {"summary": summary}
    except Exception as e:
        return {"error": str(e)}