Spaces:
Sleeping
Sleeping
Download main.py from VoltIC/Automated-Text-Summarizer: direct link, hf CLI and curl.
- Browser
- Download file 487 Bytes
-
https://huggingface.co/spaces/VoltIC/Automated-Text-Summarizer/resolve/main/main.py
- Command line
-
hf download hf://spaces/VoltIC/Automated-Text-Summarizer/main.py
-
curl -L -o main.py https://huggingface.co/spaces/VoltIC/Automated-Text-Summarizer/resolve/main/main.py
487 Bytes
| 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") | |
| ) | |
| def home(): | |
| return {"message": "Summarizer API is running!"} | |
| def summarize(text: str): | |
| try: | |
| summary = client.summarization(text) | |
| return {"summary": summary} | |
| except Exception as e: | |
| return {"error": str(e)} |