No description
Find a file
aaronjan 543d4fc14b Add result cache and disconnect detection to summarize-source endpoint
- Cache completed results by video_id to /opt/ai-services/summarizer-api/cache/
  so a re-submitted URL returns instantly instead of re-running Ollama
- Make endpoint async; monitor client disconnect every 2s via request.is_disconnected()
- Extract sync work into _summarize_video(); check stop_event between chunks so
  inference aborts promptly when the client drops rather than burning CPU to completion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 10:13:01 -07:00
bak update app.py to remove overlap between the chunk segments 2026-03-17 10:38:05 -07:00
.gitignore initial commit 2026-03-16 09:34:16 -07:00
app.py Add result cache and disconnect detection to summarize-source endpoint 2026-05-18 10:13:01 -07:00
extractors.py initial commit 2026-03-16 09:34:16 -07:00
README.md Add README 2026-05-18 06:26:55 -07:00

sauron-clipper-summary

Server-side FastAPI service running on sauron that downloads video transcripts and generates AI summaries using a local Ollama model.

How it works

Receives a URL + title from the client, detects whether it's a YouTube video or article, downloads the transcript with yt-dlp, chunks it, summarizes each chunk with Ollama (default: qwen2.5:7b), and returns a consolidated summary as JSON.

POST /summarize-source
{ "url": "https://youtu.be/...", "title": "...", "source_type": "auto" }

→ { "summary": "...", "video_id": "...", "original_transcript_chars": N, "sent_transcript_chars": N }

Files

  • app.py — FastAPI application; handles routing, chunking, Ollama calls, response assembly
  • extractors.py — yt-dlp wrapper that downloads subtitles/transcripts as JSON3 and parses them into clean text

Deployment

Runs on sauron at http://127.0.0.1:8008. Not exposed externally — the client reaches it via SSH (ssh sauron 'curl ...') or an SSH tunnel (localhost:18008 → sauron:8008).

Dependencies are installed into /opt/ai-services/summarizer-api/.venv/.

Configuration (env vars)

Variable Default Description
OLLAMA_MODEL qwen2.5:7b Model used for summarization
OLLAMA_TIMEOUT 1200 Seconds before Ollama request times out
CHUNK_TARGET_CHARS 5000 Target chunk size for transcript splitting
CHUNK_MAX_CHARS 6500 Hard cap per chunk
YT_DLP_BIN .venv/bin/yt-dlp Path to yt-dlp binary

Client counterpart

The laptop-side automation lives at clipper-video-summary-client — scans the Obsidian zettelkasten for pending clippings and calls this API.