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") @app.get("/") def home(): return {"message": "SaT Segmentation API is running. Use /segment?text=your_text_here"} @app.get("/segment") 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) }