Contextify scrapes a shared chat (ChatGPT, Claude, Mistral, Gemini) into Markdown and asks Google Gemini to extract a single, holistic context for the entire conversation. It outputs a concise JSON and a human-friendly Markdown context file.
- Mandatory model: Gemini (API)
- No local LLMs/SLMs used
- One-shot CLI to print the resulting context file path
- Install dependencies (use a venv recommended):
uv pip install -r requirements.txt- Configure environment in
.env:
GEMINI_API_KEY="your_key_here"
GEMINI_MODEL="gemini-1.5-flash" # or gemini-2.0-flash- Run one-shot CLI to get a single output path:
python contextify.py "<share_url>" --format json # prints the JSON context file path
# or Markdown context file path (default)
python contextify.py "<share_url>"Examples:
python contextify.py "https://chat.mistral.ai/chat/<id>" --format json
python contextify.py "https://g.co/gemini/share/<id>" # may require loginGiven a share URL, Contextify will:
- Scrape the chat page into Markdown (
<title>.md). - Send the full Markdown to Gemini with a strict, whole-chat context prompt.
- Save:
- JSON context:
<title>.context.json - Markdown context:
<title>.context.md
- JSON context:
JSON schema includes:
title: stringparticipants: string[]topics: string[]summary: string (<= ~180 words, holistic)key_points: string[] (<= ~7)action_items: string[] (<= ~7)entities: string[] (heuristic local extraction)
- End-to-end (prints a single path):
python contextify.py "<share_url>" --format json|md- Two-step (debugging):
python scrape_share.py "<share_url>" # -> <title>.md
python pipeline.py "<share_url>" --outdir out/ # -> writes context files; prints both pathsPlace these in .env:
GEMINI_API_KEY(required): your Gemini API keyGEMINI_MODEL(optional): defaultgemini-1.5-flash(you can setgemini-2.0-flash)
Scraping helpers (optional, for login-required pages like Gemini):
HEADLESS=0to open a visible Chrome window to log inCHROME_USER_DATA_DIR=/path/to/chrome/profileto reuse your logged-in Chrome profile
Usage examples:
HEADLESS=0 python contextify.py "<gemini_share_url>"
CHROME_USER_DATA_DIR="$HOME/.config/google-chrome" python contextify.py "<gemini_share_url>"- The full Markdown is sent to Gemini when generating the context. Unset
GEMINI_API_KEYif you don’t want any network calls (but then context generation won’t run). - Scraped
.md,.context.json,.context.mdare git-ignored by default (.gitignore).
- Missing API key:
- Error:
GEMINI_API_KEY is not set... - Fix: add to
.env, then re-run.
- Error:
- Login-required pages (Gemini):
- Use
HEADLESS=0to sign in once, orCHROME_USER_DATA_DIRto reuse your profile.
- Use
- Output looks too generic:
- Ensure you ran
contextify.py(Gemini-based) and not onlyscrape_share.py. - Try
GEMINI_MODEL=gemini-2.0-flash.
- Ensure you ran
- Rate limits/errors from API:
- Re-run after a short wait or reduce frequency.
Main files:
scrape_share.py— scrapes ChatGPT/Claude/Mistral/Gemini share pages to Markdown.analyzer.py— sends the full Markdown to Gemini; writes distilled context outputs.contextify.py— one-shot CLI: URL in, context path out.pipeline.py— end-to-end runner (prints both JSON and MD paths).
MIT