• Stars
    star
    597
  • Rank 74,465 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 1 year ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Converse with book - Built with GPT-3

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

Note: If you are using Windows, then make sure that you set the location of ImageMagick executable in the IMCONV environment variable.

# For example, if you have installed ImageMagick in PROGRAMFILES\ImageMagick-7.1.0-Q16-HDRI
set IMCONV="%PROGRAMFILES%\ImageMagick-7.1.0-Q16-HDRI\magick"

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.

From version 1.5.0, you can skip OpenAI and use HuggingFace models to generate embeddings and answers.

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

Use huggingface for generating embeddings:

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

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

To use huggingface model, provide the --llm argument:

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

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.

More Repositories

1

trading-utils

Collection of scripts and utilities for stock market analysis, strategies etc
Python
126
star
2

llm-playground

Experiments with open source LLMs
Python
60
star
3

tele-tube-rider

Telegram Bot ๐Ÿค– to download videos from Youtube, Reddit and Twitter and send it back to you.
Python
44
star
4

http-rider

Simple and Powerful desktop client for working with JSON APIs
Python
29
star
5

tele-vdo-rider

Telegram bot to convert online videos to audio (mp3)
Python
20
star
6

animate-puml

Simple animation for PlantUML diagrams
Python
13
star
7

kt-cli-app

Sample Kotlin command line application generating native image using GraalVM
Kotlin
12
star
8

pyqt-boilerplate

Boilerplate project for writing desktop applications in Python and PyQt5
Python
9
star
9

kube-rider

Desktop client for managing Kubernetes clusters
Python
9
star
10

oauth2-proxy-httpbin

Secure applications using OAuth2 Proxy
8
star
11

freqtrade-do

Setting up freqtrade (Crypto trading bot) on DigitalOcean
Makefile
8
star
12

tweetsense

Filters tweets based on sentiment analysis
JavaScript
7
star
13

fuzzy-swagger

API fuzz testing generator using swagger document.
Python
7
star
14

bin-utils

Utility scripts / apps
Python
7
star
15

mirrollama

Multiplying the Power of Ollama models
Kotlin
5
star
16

alfred-genie

Genie for Alfred
Python
5
star
17

tele-muninn

๐Ÿฆ…
Python
5
star
18

gpt-fx

ChatGPT clone with JavaFX
Kotlin
4
star
19

dev-rider

One Desktop Application For Simple Developer Tools/Utilities
Python
4
star
20

news-rider

Your own news aggregator
Python
4
star
21

chat-circuit

Branch Out Your Conversations
Python
4
star
22

py-executable-checklist

Helper classes to develop executable workflow scripts
Python
3
star
23

grails-apidocs

Plugin to generate REST Api documentation
Groovy
3
star
24

swagger-confluence

Python script to update swagger API documentation within confluence page macros
Python
3
star
25

trex-trader

Bittrex Cryptocurrency trader
Python
3
star
26

twitter-utils

Collection of twitter utilities.
Python
2
star
27

api-mocker-generator

API Mocker config and test data generator based on Swagger/OpenAPI Spec.
Python
2
star
28

lazy-trader

Instant chart and useful resources on researching stocks
JavaScript
2
star
29

crypto-folio

A simple crypto currency portfolio viewer across multiple exchanges
Python
2
star
30

voice-koder

Control IntellJ IDEA with voice commands
Python
2
star
31

dev-rider-codesnippets

Code snippets used in DevRider
Jupyter Notebook
1
star
32

apidocs-example

A sample application to use apidocs grails plugin
Groovy
1
star
33

crypto-rider

coming soon ...
Python
1
star
34

api-exchange-server-guide

Sample code for creating an AWS Lambda service with Flask and Serverless Framework
Python
1
star
35

aws-cli-runner

A simple project to demonstrate AWS SDK usage in Spring Boot
Java
1
star
36

apickli_functional_tests

A sample project for running BDD tests with [apickli](https://github.com/apickli/apickli) framework.
JavaScript
1
star
37

archived-twitter-utils

Collection of twitter utilities
HTML
1
star
38

onepage-fx

Single page application for simplifying note taking
Kotlin
1
star
39

dev-rider-osx

OSX Releases
Shell
1
star
40

orkestra

Compose interactions with APIs
Python
1
star
41

snapscan

One click, all screens, unified
Python
1
star
42

muninn

Just like Alfred but on Telegram
Python
1
star
43

bootstrap

Stuff to do for a new environment
Vim Script
1
star