Skip to main content

Unlock DeepSeek-V4's 1M context window โ€” chat with entire codebases, books, and email archives

Project description

๐Ÿš€ deepseek-1M

Chat with your entire codebase, documents, or email archive โ€” using DeepSeek-V4's 1,000,000-token context window.

No chunking. No embeddings. No RAG. Just DeepSeek-V4 holding everything in memory.

Python 3.10+ License: MIT DeepSeek V4 Stars


What is this?

DeepSeek-V4 just launched with a 1,000,000 token context window โ€” that's roughly:

What How much
Lines of code ~30,000 lines
Pages of text ~2,500 pages
Emails ~5,000 emails
Novels ~6 full-length books

deepseek-1M is a toolkit that makes this actually useful. Load any source, chat freely.


Demo

Demo Demo

๐Ÿ—‚ Chat with a GitHub Repo

export DEEPSEEK_API_KEY=your_key
deepseek-1m chat --repo https://github.com/fastapi/fastapi
๐Ÿ“ฆ Loaded: github.com/tiangolo/fastapi@master
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Stat                 โ”‚ Value              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Files loaded         โ”‚ 347                โ”‚
โ”‚ Total characters     โ”‚ 1,842,391          โ”‚
โ”‚ Est. tokens          โ”‚ ~460,598           โ”‚
โ”‚ Context utilization  โ”‚ 46.1% of 1M        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

You: How does FastAPI handle dependency injection?

DeepSeek-V4: FastAPI's dependency injection is handled through the `Depends()`
function in `fastapi/dependencies/utils.py`. When you declare a path operation:

    @app.get("/items/")
    async def read_items(db: Session = Depends(get_db)):

FastAPI calls `solve_dependencies()` which recursively resolves the dependency
graph. The key files are:
- `fastapi/dependencies/utils.py` โ€” core resolution logic (line 462: `solve_dependencies`)
- `fastapi/params.py` โ€” the `Depends` class definition
- `fastapi/_compat.py` โ€” Pydantic v1/v2 compatibility layer for parameter types

Sub-dependencies are cached per request by default via `use_cache=True`...

๐Ÿ“š Analyze a Full PDF

deepseek-1m chat --pdf research_paper.pdf --model deepseek-v4-pro --thinking

๐Ÿ“ง Chat With Your Email Archive

# Export from Gmail: takeout.google.com โ†’ Mail โ†’ .mbox
deepseek-1m chat --mbox ~/Downloads/mail.mbox
You: Who have I emailed most in the past year?

DeepSeek-V4: Based on your archive (2,847 emails loaded), your top contacts are:

1. sarah@company.com โ€” 312 emails (mostly project coordination, Q3 launch)
2. dev-team@company.com โ€” 287 emails (code reviews, standups)
3. john.smith@client.com โ€” 156 emails (contract negotiations, ongoing since March)
...

You: Did anyone ever follow up on the Q3 budget discussion?

DeepSeek-V4: Yes โ€” there were 3 emails about Q3 budget:
- Aug 12: You sent initial proposal to finance@company.com
- Aug 15: Mike replied asking for revised numbers
- Aug 17: You sent revised version

But I don't see any response after Aug 17. This thread appears unresolved.

Install

pip install deepseek-1m

# With PDF support
pip install "deepseek-1m[pdf]"

# With web demo
pip install "deepseek-1m[all]"

Quickstart

Python API

from deepseek_1m import load, Session

# Load a GitHub repo
ctx = load("https://github.com/fastapi/fastapi")

# Start chatting โ€” the whole repo is in memory
session = Session(context=ctx)
session.chat()
# Load a local project
ctx = load("./my-project")
session = Session(context=ctx)
answer = session.ask("What does this codebase do?")
# Load a PDF
from deepseek_1m import load_pdf, Session

ctx = load_pdf("contract.pdf")
session = Session(context=ctx)
session.chat()
# One-liner for quick questions (no context needed)
from deepseek_1m import ask
print(ask("Explain quantum entanglement in one sentence."))

Async

import asyncio
from deepseek_1m import DeepSeekClient

async def main():
    client = DeepSeekClient(model="deepseek-v4-pro")
    response = await client.achat(
        messages=[{"role": "user", "content": "Hello!"}]
    )
    print(response.content)

asyncio.run(main())

Thinking Mode (Chain-of-Thought)

client = DeepSeekClient(
    model="deepseek-v4-pro",
    thinking=True,
    reasoning_effort="high",
)
session = Session(client=client, show_thinking=True)
session.chat()

Web Demo

pip install "deepseek-1m[all]"
streamlit run demo/app.py

Opens a beautiful web UI at http://localhost:8501:

  • Upload a PDF, paste a GitHub URL, or point to a local folder
  • Real-time context utilization bar (% of 1M window used)
  • One-click suggested prompts
  • Live cost and token tracking

CLI Reference

deepseek-1m chat --repo <github_url>         # GitHub repo
deepseek-1m chat --folder <path>             # Local directory
deepseek-1m chat --pdf <file.pdf>            # PDF document
deepseek-1m chat --mbox <file.mbox>          # Email archive
deepseek-1m chat --url <https://...>         # Web page

deepseek-1m ask "your question"              # Quick one-off question
deepseek-1m demo                             # Launch web UI

Options:
  --model   deepseek-v4-flash (default, fast) | deepseek-v4-pro (best)
  --thinking                                 Enable chain-of-thought
  --github-token <token>                     For private repos

Session Commands (during chat)

/tokens    โ€” Show context utilization and cost so far
/thinking  โ€” Toggle thinking mode display on/off
/save      โ€” Save conversation to JSON
/clear     โ€” Clear conversation (keeps context loaded)
/exit      โ€” Quit

Supported Sources

Source Command Notes
GitHub repo (public) load("https://github.com/owner/repo") All text files, recursive
GitHub repo (private) load_github(url, token="ghp_...") Requires PAT
Local directory load("./my-project") Recursive, skips binaries
Single file load("./script.py") Any text file
PDF document load_pdf("doc.pdf") Text extraction
Email archive load_mbox("mail.mbox") Gmail, Outlook, Apple Mail
Web page load("https://example.com") Text extraction

Architecture

deepseek_1m/
โ”œโ”€โ”€ client.py      # DeepSeek-V4 API client (sync + async, streaming, retry)
โ”œโ”€โ”€ loader.py      # Universal source loader (GitHub, local, PDF, mbox, URL)
โ”œโ”€โ”€ session.py     # Stateful chat session with 1M context management
โ””โ”€โ”€ __main__.py    # CLI entry point

examples/
โ”œโ”€โ”€ codebase_chat.py    # Full GitHub/local repo chat
โ”œโ”€โ”€ book_analysis.py    # PDF document analysis
โ””โ”€โ”€ email_archive.py    # Email archive chat

demo/
โ””โ”€โ”€ app.py              # Streamlit web interface

tests/
โ””โ”€โ”€ test_core.py        # 30+ tests covering all core functionality

How the 1M Context Works

Traditional approaches to "chat with your data":

Your codebase โ†’ chunk into pieces โ†’ embed each chunk โ†’ vector database
โ†’ similarity search at query time โ†’ hope the right chunks are retrieved

deepseek-1M:

Your codebase โ†’ one big string โ†’ DeepSeek-V4 (1M tokens) โ†’ answer

No retrieval. No missed context. No hallucinated answers because the right chunk wasn't retrieved. The model sees everything simultaneously.

This only became practical with DeepSeek-V4's efficient attention architecture (Compressed Sparse Attention), which uses only 27% of single-token FLOPs and 10% of the KV cache of V3 at 1M tokens.


Cost Estimates

Source Typical Size Flash Cost Pro Cost
Medium GitHub repo (300 files) ~400K tokens ~$0.028/query ~$0.108/query
Research paper (100 pages) ~80K tokens ~$0.006/query ~$0.022/query
1,000 emails ~150K tokens ~$0.011/query ~$0.041/query
Large monorepo (2000 files) ~900K tokens ~$0.063/query ~$0.243/query

Input token pricing: Flash $0.07/1M, Pro $0.27/1M. Context caching reduces repeat costs significantly.


Requirements

  • Python 3.10+
  • DeepSeek API key (get one free)
  • openai, rich, tiktoken (installed automatically)

Optional: pypdf for PDFs, beautifulsoup4 for URLs, streamlit for web demo.


Contributing

Contributions welcome! Ideas for new loaders:

  • Notion workspace
  • Google Docs / Drive
  • Slack export (JSON format)
  • Confluence pages
  • YouTube transcripts
  • Audio transcription โ†’ context
git clone https://github.com/yourusername/deepseek-1M
cd deepseek-1M
pip install -e ".[dev]"
pytest tests/ -v

License

MIT โ€” use it, fork it, ship it.


Built in response to DeepSeek-V4's April 2026 launch with 1M token context.
If this saved you time, give it a โญ โ€” it helps others find it.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepseek_1m-1.0.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepseek_1m-1.0.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file deepseek_1m-1.0.0.tar.gz.

File metadata

  • Download URL: deepseek_1m-1.0.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for deepseek_1m-1.0.0.tar.gz
Algorithm Hash digest
SHA256 18a0a5bd829e02d743e48da31d21637ec4b8efbcc841ffe1c7d57dbbff36e36a
MD5 57f45f276d7f308b65d0bf5e0fba5c04
BLAKE2b-256 035271832c34b67825d7aa69d7e2d2f5fe8219fb2fb5d19e17d6c5934c169571

See more details on using hashes here.

File details

Details for the file deepseek_1m-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: deepseek_1m-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for deepseek_1m-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8dd8dec4ff818edacb782cf6ae340f48f759c570a52e92f0a70a66a23153551
MD5 cea52f44d3eba6062f398bcd418d87be
BLAKE2b-256 8fa81ec489c97a180e8fce8701071390a3da3e1221936d3b4d8ea64ddc3d43eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page