{"_id":"@behagoras/chat-with-pdf","_rev":"58-a7e37d2284725809432333f63dd0e9e6","name":"@behagoras/chat-with-pdf","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.2":{"name":"@behagoras/chat-with-pdf","version":"0.0.2","keywords":["rag","pdf","openai","cli","chat"],"license":"MIT","_id":"@behagoras/chat-with-pdf@0.0.2","maintainers":[{"name":"behagoras","email":"davbelom@gmail.com"}],"bin":{"pdf-qa":"dist/cli.js","chat-with-pdf":"dist/cli.js"},"dist":{"shasum":"5ef253feff808f91a71fe5b617c043ba2b4f491c","tarball":"https://registry.npmjs.org/@behagoras/chat-with-pdf/-/chat-with-pdf-0.0.2.tgz","fileCount":3,"integrity":"sha512-USmpqZnDeu/u74CEWBsV1GJCMGkcLIBtH7pEy4ymcLxyD7FvqAqZ6oBU1lUwJJjERj4O4Gi7xpqUM0NUsi87Lg==","signatures":[{"sig":"MEUCIFbPQsaCbKmGvTVl0usCxgCZxnf2J0EjNI0j7N2SYSBWAiEAi1sEbyiLEDRcO+AAKEfQKPfsSpXSEcZtcCD/3RnZHkA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23063},"type":"module","engines":{"node":">=18"},"gitHead":"c4d5ffe0097ad96377f257834de4a0d4b3fc8bda","private":false,"scripts":{"dev":"tsx src/cli.ts","build":"tsc -p tsconfig.json","start":"node dist/cli.js","release":"node scripts/release.mjs","prepublishOnly":"npm run build"},"_npmUser":{"name":"behagoras","email":"davbelom@gmail.com"},"_npmVersion":"10.9.3","description":"Local PDF QA CLI (RAG) with OpenAI chat + embeddings.","directories":{},"_nodeVersion":"22.20.0","dependencies":{"zod":"^3.23.8","dotenv":"^16.4.5","openai":"^4.62.1","commander":"^12.1.0","pdf-parse":"^2.4.3","pdfjs-dist":"^4.10.38"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","typescript":"^5.6.3","@types/node":"^20.12.12"},"_npmOperationalInternal":{"tmp":"tmp/chat-with-pdf_0.0.2_1760665043032_0.8991392676706429","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@behagoras/chat-with-pdf","version":"0.0.3","keywords":["rag","pdf","openai","cli","chat"],"license":"MIT","_id":"@behagoras/chat-with-pdf@0.0.3","maintainers":[{"name":"behagoras","email":"davbelom@gmail.com"}],"bin":{"pdf-qa":"dist/cli.js","chat-with-pdf":"dist/cli.js"},"dist":{"shasum":"15898113ddfc0b4cf17aeaeca9a5cd5da6861667","tarball":"https://registry.npmjs.org/@behagoras/chat-with-pdf/-/chat-with-pdf-0.0.3.tgz","fileCount":3,"integrity":"sha512-BxBYF4gJ6NF3dX+w1v1Xn44JYt4GYJJ+TcuFEXNc4AOWOle3i3Xvz5tnkWUcdkO2ui1bpYhq+k/oIFk2vE7JmA==","signatures":[{"sig":"MEUCIHgQdgAjT5pJKMNNArNKd+fcyyOEnI50FeebXu1Wzb4rAiEAzURKKLvkjw4H5FfKyVDHcGst4mmpiJhxjntBjNHYA1Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":23423},"type":"module","engines":{"node":">=18"},"gitHead":"718dc849c7e7eb0e036b69739ba25b225b36ecb2","private":false,"scripts":{"dev":"tsx src/cli.ts","build":"tsc -p tsconfig.json","start":"node dist/cli.js","release":"node scripts/release.mjs","prepublishOnly":"npm run build"},"_npmUser":{"name":"behagoras","email":"davbelom@gmail.com"},"_npmVersion":"10.9.3","description":"Local PDF QA CLI (RAG) with OpenAI chat + embeddings.","directories":{},"_nodeVersion":"22.20.0","dependencies":{"zod":"^3.23.8","dotenv":"^16.4.5","openai":"^4.62.1","commander":"^12.1.0","pdf-parse":"^2.4.3","pdfjs-dist":"^4.10.38"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","typescript":"^5.6.3","@types/node":"^20.12.12"},"_npmOperationalInternal":{"tmp":"tmp/chat-with-pdf_0.0.3_1760665371117_0.2968715753974709","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@behagoras/chat-with-pdf","version":"0.0.4","type":"module","private":false,"scripts":{"dev":"tsx src/cli.ts","build":"tsc -p tsconfig.json","start":"node dist/cli.js","prepublishOnly":"npm run build","release":"node scripts/release.mjs"},"bin":{"chat-with-pdf":"dist/cli.js","pdf-qa":"dist/cli.js"},"publishConfig":{"access":"public"},"engines":{"node":">=18"},"description":"Local PDF QA CLI (RAG) with OpenAI chat + embeddings.","license":"MIT","keywords":["rag","pdf","openai","cli","chat"],"dependencies":{"commander":"^12.1.0","dotenv":"^16.4.5","openai":"^4.62.1","pdf-parse":"^2.4.3","pdfjs-dist":"^4.10.38","zod":"^3.23.8"},"devDependencies":{"@types/node":"^20.12.12","tsx":"^4.19.2","typescript":"^5.6.3"},"_id":"@behagoras/chat-with-pdf@0.0.4","gitHead":"fb1069aebff1c9b7919e4da0ef6e624dab34f76f","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-Uf61DY7/oW3ejUKb+eq2bM0dKHJWgYIMvKh58d4qjpE1RKUsDte7YwBvOQY/fbOQHK6R6DVioDQQYSSjLFsugQ==","shasum":"6272856db7a840265cfc27194ab575463f2422c6","tarball":"https://registry.npmjs.org/@behagoras/chat-with-pdf/-/chat-with-pdf-0.0.4.tgz","fileCount":3,"unpackedSize":23488,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHBQ2U8Pzcz4DrxJMNJtPfMztFgEkrU0Q1RdmSDk/D9HAiAY/lim5n/6wJ0c4w+kM0kdwBGqy44ehVbnOplxuzkaag=="}]},"_npmUser":{"name":"behagoras","email":"davbelom@gmail.com"},"directories":{},"maintainers":[{"name":"behagoras","email":"davbelom@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/chat-with-pdf_0.0.4_1760665725377_0.813428653280623"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-17T01:37:22.926Z","modified":"2025-10-17T01:48:45.762Z","0.1.2":"2025-10-17T00:58:21.159Z","0.1.3":"2025-10-17T01:03:15.428Z","0.1.4":"2025-10-17T01:05:48.915Z","0.1.5":"2025-10-17T01:30:42.162Z","0.1.6":"2025-10-17T01:30:45.971Z","0.1.7":"2025-10-17T01:30:50.173Z","0.1.8":"2025-10-17T01:30:53.856Z","0.1.9":"2025-10-17T01:30:58.225Z","0.1.10":"2025-10-17T01:31:02.676Z","0.1.11":"2025-10-17T01:31:06.969Z","0.1.12":"2025-10-17T01:31:11.144Z","0.1.13":"2025-10-17T01:31:15.349Z","0.1.14":"2025-10-17T01:31:19.324Z","0.1.15":"2025-10-17T01:31:23.445Z","0.1.16":"2025-10-17T01:31:27.447Z","0.1.17":"2025-10-17T01:31:30.809Z","0.1.18":"2025-10-17T01:31:34.889Z","0.1.19":"2025-10-17T01:31:38.573Z","0.1.20":"2025-10-17T01:31:42.644Z","0.1.21":"2025-10-17T01:31:46.534Z","0.1.22":"2025-10-17T01:31:50.736Z","0.1.23":"2025-10-17T01:31:54.694Z","0.1.24":"2025-10-17T01:32:00.610Z","0.1.25":"2025-10-17T01:32:04.357Z","0.1.26":"2025-10-17T01:32:08.805Z","0.1.27":"2025-10-17T01:32:12.205Z","0.1.28":"2025-10-17T01:32:16.657Z","0.1.29":"2025-10-17T01:32:20.611Z","0.1.30":"2025-10-17T01:32:24.920Z","0.1.31":"2025-10-17T01:32:28.709Z","0.1.32":"2025-10-17T01:32:32.838Z","0.1.33":"2025-10-17T01:32:37.166Z","0.1.34":"2025-10-17T01:32:41.734Z","0.1.35":"2025-10-17T01:32:46.081Z","0.1.36":"2025-10-17T01:32:50.466Z","0.1.37":"2025-10-17T01:32:54.307Z","0.1.38":"2025-10-17T01:33:00.433Z","0.1.39":"2025-10-17T01:33:05.105Z","0.1.40":"2025-10-17T01:33:09.122Z","0.1.41":"2025-10-17T01:33:13.073Z","0.1.42":"2025-10-17T01:33:17.460Z","0.1.43":"2025-10-17T01:33:21.561Z","0.1.44":"2025-10-17T01:33:26.005Z","0.1.45":"2025-10-17T01:33:30.200Z","0.1.46":"2025-10-17T01:33:33.818Z","0.1.47":"2025-10-17T01:33:37.846Z","0.1.48":"2025-10-17T01:33:42.184Z","0.1.49":"2025-10-17T01:33:46.584Z","0.1.50":"2025-10-17T01:33:50.640Z","0.1.51":"2025-10-17T01:33:54.320Z","0.1.52":"2025-10-17T01:33:59.023Z","0.1.53":"2025-10-17T01:34:03.071Z","0.1.54":"2025-10-17T01:34:07.236Z","0.0.2":"2025-10-17T01:37:23.228Z","0.0.3":"2025-10-17T01:42:51.318Z","0.0.4":"2025-10-17T01:48:45.574Z"},"license":"MIT","keywords":["rag","pdf","openai","cli","chat"],"description":"Local PDF QA CLI (RAG) with OpenAI chat + embeddings.","maintainers":[{"name":"behagoras","email":"davbelom@gmail.com"}],"readme":"# @behagoras/chat-with-pdf\n\nLocal PDF QA CLI (RAG) with OpenAI chat + embeddings. Ingest PDFs to a JSON index on disk and ask grounded questions with inline citations. Includes an interactive chat mode with short-term conversation memory.\n\n- npm: `@behagoras/chat-with-pdf`\n- Repo: https://github.com/behagoras/chat-with-pdf\n\n## Installation\n\n- Global (recommended):\n```bash\nnpm i -g @behagoras/chat-with-pdf@latest\n# ensure npm global bin is on PATH\n```\n\nSet your OpenAI key (env or flag):\n```bash\nexport OPENAI_API_KEY=sk-...\n```\nor pass per-command\n```bash\n# --openai-key sk-...\n```\nor persist your key once:\n```bash\nchat-with-pdf auth:set sk-...\n```\nFor managing your key, you can use the following commands:\n```bash\nchat-with-pdf auth:set sk-...\nchat-with-pdf auth:show ## We won't show the key, but it will be stored in ~/.config/chat-with-pdf/config.json\n# to remove it:\nchat-with-pdf auth:clear\n```\n\n## Quick Start\n\n1) Ingest one or more PDFs\n```bash\nchat-with-pdf ingest ./my.pdf -o ./pdfqa.index.json\n# or with a specific openai key\nchat-with-pdf ingest ./my.pdf -o ./pdfqa.index.json --openai-key sk-...\n# multiple pdf's to be indexed\nchat-with-pdf ingest ./a.pdf ./b.pdf -o ./pdfqa.index.json\n```\n\n2) Ask one-off\n```bash\n# one-off question\nchat-with-pdf ask -i ./pdfqa.index.json \"Where do I start?\"\n# with a specific openai key\nchat-with-pdf ask -i ./pdfqa.index.json --openai-key sk-... \"Where do I start?\"\n```\n\n3) Interactive chat\n```bash\n# interactive chat\nchat-with-pdf chat -i ./pdfqa.index.json\n# then type follow-ups; quit with q, quit, :q or exit (or Ctrl+C)\n```\n\nOptions:\n- `--model` (default `gpt-4o-mini`) gpt5 is not supported yet\n- `--embed-model` (default `text-embedding-3-small`)\n- `--top-k` retrieval size (default 5)\n- `--json` for structured output\n- `--openai-key` specific openai key\n- `--save <path>` save conversation JSON to path\n- `--index <path>` index path (default `./pdfqa.index.json`)\n\n## Architecture\n\n- Functional core, IO at edges for easy swapping:\n  - PDF extraction: `pdf-parse` first, fallback `pdfjs-dist` (legacy build) for page text\n  - Chunking: simple character-based with overlap\n  - Embeddings: OpenAI `text-embedding-3-*`\n  - Retrieval: in-memory cosine over JSON index\n  - Chat: OpenAI chat completions (`gpt-4o-mini` default)\n  - ModelProvider interface allows swapping providers\n\n- Conversation memory:\n  - Interactive `chat` keeps a small rolling window of (Q, A) turns\n  - Retrieval is conditioned on recent turns to resolve referents\n  - Prompt includes PRIOR_CONVERSATION and retrieved CONTEXT\n\n- Clean seams to grow:\n  - Replace JSON with SQLite + sqlite-vec (swap persistence + retrieval)\n  - Add streaming responses\n  - Per-page citations\n\n## Commands\n\n- `ingest [options] <files...>`\n  - `-o, --out` index path (default `./pdfqa.index.json`)\n  - `--chunk` target characters (default 3500)\n  - `--overlap` characters (default 200)\n  - `--embed-model` embedding model\n\n- `ask [options] <question...>`\n  - One-off Q&A; prints answer and citations\n\n- `chat [options] [question...]`\n  - Interactive loop; optional initial question\n  - Quit with `q`, `quit`, `:q`, or `exit` (or Ctrl+C)\n\n## Release/publish (maintainers)\n\nRelease a new version (defaults to patch):\n```bash\nnpm run release\nnpm run release patch\nnpm run release minor\nnpm run release major\n```\n\n## Requirements\n\n- Node.js >= 18\n- `OPENAI_API_KEY` in environment\n\n## Repository\n\n- Source and issues: https://github.com/behagoras/chat-with-pdf\n\n## License\n\nMIT © 2025 David Behar\n","readmeFilename":"README.md"}