Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

Contextify

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

Quick Start

  1. Install dependencies (use a venv recommended):
uv pip install -r requirements.txt
  1. Configure environment in .env:
GEMINI_API_KEY="your_key_here"
GEMINI_MODEL="gemini-1.5-flash"   # or gemini-2.0-flash
  1. 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 login

What it produces

Given 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 schema includes:

  • title: string
  • participants: string[]
  • topics: string[]
  • summary: string (<= ~180 words, holistic)
  • key_points: string[] (<= ~7)
  • action_items: string[] (<= ~7)
  • entities: string[] (heuristic local extraction)

Commands

  • 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 paths

Environment variables

Place these in .env:

  • GEMINI_API_KEY (required): your Gemini API key
  • GEMINI_MODEL (optional): default gemini-1.5-flash (you can set gemini-2.0-flash)

Scraping helpers (optional, for login-required pages like Gemini):

  • HEADLESS=0 to open a visible Chrome window to log in
  • CHROME_USER_DATA_DIR=/path/to/chrome/profile to 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>"

Notes on privacy

  • The full Markdown is sent to Gemini when generating the context. Unset GEMINI_API_KEY if you don’t want any network calls (but then context generation won’t run).
  • Scraped .md, .context.json, .context.md are git-ignored by default (.gitignore).

Troubleshooting

  • Missing API key:
    • Error: GEMINI_API_KEY is not set...
    • Fix: add to .env, then re-run.
  • Login-required pages (Gemini):
    • Use HEADLESS=0 to sign in once, or CHROME_USER_DATA_DIR to reuse your profile.
  • Output looks too generic:
    • Ensure you ran contextify.py (Gemini-based) and not only scrape_share.py.
    • Try GEMINI_MODEL=gemini-2.0-flash.
  • Rate limits/errors from API:
    • Re-run after a short wait or reduce frequency.

Development

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).

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages