Spaces:
Paused
Paused
| from fastapi import FastAPI, Query | |
| from wtpsplit import SaT | |
| app = FastAPI() | |
| # Load the model once during startup | |
| # 'sat-3l-sm' is fast and efficient for CPU Spaces | |
| model = SaT("sat-3l-sm") | |
| def home(): | |
| return {"message": "SaT Segmentation API is running. Use /segment?text=your_text_here"} | |
| def segment_text(text: str = Query(..., description="The text you want to split into sentences")): | |
| # Perform the segmentation | |
| sentences = model.split(text) | |
| return { | |
| "input": text, | |
| "sentences": sentences, | |
| "count": len(sentences) | |
| } |