An AI-powered FastAPI service that corrects spelling and grammar in PowerPoint files using Claude Sonnet 4.5 via the Langdock API. Consultants upload a .pptx to Langdock, Langdock’s sandbox sends it to the backend, and the backend returns a corrected file as a base64 payload.
The service preserves formatting at the run level and supports an optional highlighted output mode for reviewed changes. It is designed for Railway deployment in the EU region with in-memory job processing and no file writes during correction.
Langdock custom action
|
| POST /jobs?highlight=false
| Body: { file_base64, file_name }
v
FastAPI backend on Railway
|
| Background job
| - decode base64 into BytesIO
| - extract text from slides
| - call Langdock LLM API
| - preserve formatting and optionally highlight changes
| - store result in jobs dict
v
GET /jobs/{job_id}
|
| { status: processing | done | error }
v
Langdock action returns corrected PPTX file
GET /health
{ "status": "ok" }POST /jobs?highlight=false
Headers:
Authorization: Bearer <API_KEY>
Body:
{
"file_base64": "...",
"file_name": "presentation.pptx"
}Response:
{ "job_id": "<uuid>" }GET /jobs/{job_id}
Headers:
Authorization: Bearer <API_KEY>
Responses:
{ "status": "processing" }{
"status": "done",
"file_base64": "...",
"file_name": "presentation_corrected.pptx",
"corrections_count": 12,
"changes": [
{ "slide": 1, "original": "Teh strategc obiectives for Q3", "corrected": "The strategic objectives for Q3" }
]
}{ "status": "error", "message": "..." }python -m venv venv
venv\Scripts\activate
pip install -r requirements-dev.txt
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000| Variable | Required | Purpose |
|---|---|---|
API_KEY |
Yes | Bearer token required on /jobs endpoints |
LANGDOCK_API_KEY |
Yes | Langdock API key for Claude calls |
LANGDOCK_API_URL |
Yes | Langdock completions endpoint |
PORT |
Yes in Railway | Port for FastAPI / Uvicorn |
Optional:
| Variable | Purpose |
|---|---|
LANGDOCK_MODEL |
Override the Claude model if needed |
- Create a custom integration in Langdock.
- Add a file input named
document. - Add a boolean input named
highlight, defaulting tofalse. - Add an API key auth field that stores the backend bearer token.
- Paste the reference action from
langdock/action_correct_pptx.js. - Configure the action to call the Railway service URL for
POST /jobsandGET /jobs/{job_id}. - Set the auth field slug to
apiKey, or update the script to use your chosendata.auth.<slug>value.
Important: Langdock documents a 2-minute execution timeout for custom actions. The reference script polls in the sandbox, but it must still fit inside that timeout budget. If a job is still processing when the sandbox limit is reached, the action should return a clear in-progress error and let the user retry.
- Create a Railway service from this repository.
- Use the root
Dockerfile. - Set the Railway region to EU West Metal, Amsterdam in the Railway dashboard.
- Add the runtime variables
API_KEY,LANGDOCK_API_KEY,LANGDOCK_API_URL, andPORT. - Configure the health check path as
/health.
venv\Scripts\python.exe -m pytest tests/ -v --tb=short- Processing is fully in memory.
- No files are written to disk during correction.
- The FastAPI job store is ephemeral; a restart clears pending jobs.
- The backend keeps the original McKinsey-style correction prompt and run-level formatting preservation logic.