Skip to main content

Search through a document using a chat interface

Project description

Doc Search

PyPI PyPI - Python Version PyPI - License

Converse with a book (PDF)

See tweet for full demo.


Documentation: https://namuan.github.io/dr-doc-search

Source Code: https://github.com/namuan/dr-doc-search

PyPI: https://pypi.org/project/dr-doc-search/


Pre-requisites

Installation

pip install dr-doc-search

Example Usage

There are two steps to use this application:

1. First, you need to create the index and generate embeddings for the PDF file. Here I'm using a PDF file generated from this page Parable of a Monetary Economy

Before running this, you need to set up your OpenAI API key. You can get it from OpenAI.

export OPENAI_API_KEY=<your-openai-api-key>

The run the following command to start the training process:

dr-doc-search --train -i ~/Downloads/parable-of-a-monetary-economy-heteconomist.pdf

The training process generates some temporary files in the OutputDir/dr-doc-search/<pdf-name> folder under your home directory. Here is what it looks like:

 ~/OutputDir/dr-doc-search/parable-of-a-monetary-economy-heteconomist
$ tree
.
├── images
│ ├── output-1.png
│ ├── output-10.png
│ ├── output-11.png
...
│ └── output-9.png
├── index
│ ├── docsearch.index
│ └── index.pkl
├── parable-of-a-monetary-economy-heteconomist.pdf
└── scanned
    ├── output-1.txt
    ...
    └── output-9.txt

Note: It is possible to change the base of the output directory by providing the --app-dir argument.

2. Now that we have the index, we can use it to start asking questions.

dr-doc-search -i ~/Downloads/parable-of-a-monetary-economy-heteconomist.pdf --input-question "How did the attempt to reduce the debut resulted in decrease in employment?"

Or You can open up a web interface (on port :5006) to ask questions:

dr-doc-search --web-app -i ~/Downloads/parable-of-a-monetary-economy-heteconomist.pdf

There are more options for choose the start and end pages for the PDF file. See the help for more details:

dr-doc-search --help

Acknowledgements

Development

  • Clone this repository

  • Requirements:

  • Create a virtual environment and install the dependencies

poetry install
  • Activate the virtual environment
poetry shell

Validating build

make build

Release process

A release is automatically published when a new version is bumped using make bump. See .github/workflows/build.yml for more details. Once the release is published, .github/workflows/publish.yml will automatically publish it to PyPI.

Disclaimer

This project is not affiliated with OpenAI. The OpenAI API and GPT-3 language model are not free after the trial period.

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

dr_doc_search-1.4.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

dr_doc_search-1.4.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file dr_doc_search-1.4.1.tar.gz.

File metadata

  • Download URL: dr_doc_search-1.4.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1030-azure

File hashes

Hashes for dr_doc_search-1.4.1.tar.gz
Algorithm Hash digest
SHA256 bfc7978bfdb08b8381006622425976cd5354c0e98831f7497cc16559a9e98d07
MD5 7f594f45806c7a3e97acb65cb83b636b
BLAKE2b-256 f6f3d1ff3c9cf898c984777e0532bad1e7119861d0b69c5ee8160a69f5b932aa

See more details on using hashes here.

File details

Details for the file dr_doc_search-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: dr_doc_search-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.9.16 Linux/5.15.0-1030-azure

File hashes

Hashes for dr_doc_search-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4f26eeceaeac2ec68e33163f54bb51639e00cbd3fadf4d6b1b45dc20e048cee9
MD5 478f6746273f0206913061d2b3739bb4
BLAKE2b-256 e761a076ee3da82a5b2c66f0f6f3ff991ea1e9528c8f6ba98a129acd8c51e303

See more details on using hashes here.

Supported by

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