Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .devops/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM python:3.11.2-slim
LABEL authors="clov"
FROM python:3.11.2
LABEL authors="hdc"

# Setup env
ENV LANG C.UTF-8
Expand All @@ -12,21 +12,32 @@ ENV PORT_NUMBER 8501
WORKDIR /app

# Update apt-get and install gcc
RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install apt-utils && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/*

# install pg_config
RUN apt-get update && apt-get install wget ca-certificates -y && apt-get install -y gnupg2
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list'&& apt-get update && apt-get install postgresql postgresql-contrib -y

# Install python dependencies in /.venv
COPY Pipfile .
COPY Pipfile.lock .
#COPY Pipfile .
#COPY Pipfile.lock .
COPY requirments.txt .

# Install pipenv and compilation dependencies
RUN pip install -U setuptools pip pipenv
RUN pipenv install --system --deploy
#RUN pip install -U setuptools pip pipenv
#RUN pipenv install --system --deploy
RUN pip install -r requirments.txt

# Copy project on mac
#COPY .. .

# on linux machine access control do not allow copy outside path
COPY . .


# Copy project
COPY .. .

# Rename .env.docker file to .env
RUN mv .env.dev .env

# Command to run when app starts
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=$PORT_NUMBER", "--server.address=0.0.0.0"]
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
6 changes: 4 additions & 2 deletions .devops/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.8'
version: '3.3'

services:
app:
Expand All @@ -7,4 +7,6 @@ services:
dockerfile: .devops/Dockerfile
container_name: chatbot
expose:
- "8501"
- "8501"
ports:
- "8501:8501"
12 changes: 6 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ name = "pypi"

[packages]
python-dotenv = "1.0.0"
streamlit = "1.22.0"
langchain = "0.0.174"
openai = "0.27.7"
streamlit = "1.24.0"
langchain = "0.0.216"
openai = "0.27.8"
tiktoken = "0.4.0"
pypdf = "3.8.1"
chromadb = "0.3.23"
pypdf = "3.11.0"
chromadb = "0.3.26"
streamlit-extras = "0.2.7"
streamlit-chat = "0.0.2.2"
streamlit-chat = "0.1.1"

[dev-packages]

Expand Down
1,571 changes: 703 additions & 868 deletions Pipfile.lock

Large diffs are not rendered by default.

124 changes: 66 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,66 @@
# Chat with PDF (or any other document)

![pdf chat-bot (preview)](docs/chat-bot.png)

This is still very much a work in progress, meaning it ain't production-ready
(and to be fair to myself, it was a good excuse to try out ChatGPT 😃).

## Usage
Make a copy of [.env.dev](.env.dev) file named `.env`,
and make sure all the **ENVIRONMENT_VARIABLES** are set - of importance,
the **OPENAI_API_KEY** must be present and set.

```bash
cp .env.dev .env # make a copy of .env.dev called .env
```

### Development (for now 😂)

Prerequisites:

- [Python](https://www.python.org/downloads/release/python-3112/)
- [Pipenv](https://pipenv.pypa.io/en/latest/)
- [Git](https://git-scm.com/)
- Obtain an [OpenAI API Key](https://platform.openai.com/account/api-keys)

With [Docker](https://www.docker.com/):

Make sure you have both [docker](https://www.docker.com/) and
[docker-compose](https://docs.docker.com/compose/) installed locally.

```bash
docker-compose -f .devops/docker-compose.yml up --build
````

Without [Docker](https://www.docker.com/):

```bash
$ git clone https://github.com/clovisphere/chat-with-pdf.git # clone the repo
$ cd chat-with-pdf # cd into project root
$ pipenv install # install dependencies
$ pipenv shell # activate virtualenv
$ python -m streamlit run app.py # or streamlit run app.py
```

If all went well, your app should be available on [http://127.0.0.1:8501](http://127.0.0.1:8501)


## Author

Clovis Mugaruka

- [github.com/clovisphere](https://github.com/clovisphere)
- [twitter/clovisphere](https://twitter.com/clovisphere)

## License

Copyright ©️ 2023, [Clovis Mugaruka](https://clovisphere.com).\
Released under the [MIT License](LICENSE).
# preview demo video

![img.png](docs/img.png)
![img_1.png](docs/img_1.png)
# Step 1 Cloud resources
## 1.1 create ecs with security group 8501 open
![img_2.png](docs/img_2.png)
![img_3.png](docs/img_3.png)

### need to create/ select if you have vpc setup
![img_4.png](docs/img_4.png)
### create security group
![img_5.png](docs/img_5.png)
![img_6.png](docs/img_6.png)
![img_7.png](docs/img_7.png)
![img_8.png](docs/img_8.png)
![img_9.png](docs/img_9.png)
![img_10.png](docs/img_10.png)
## 1.2 create adbpg with fastann enabled
![img_11.png](docs/img_11.png)
![img_12.png](docs/img_12.png)=
### this will take a around 10-15 mins,
### get the public access endpoint:
![img_14.png](docs/img_14.png)
![img_15.png](docs/img_15.png)
### create admin account
![img_16.png](docs/img_16.png)
eg:
username: aigcpostgres ,password: alibabacloud666
![img_17.png](docs/img_17.png)
### create a database with name: aigcpostgres
![img_18.png](docs/img_18.png)
![img_19.png](docs/img_19.png)
For more information about DMS, please refer to [here](https://www.alibabacloud.com/help/en/data-management-service/latest/log-on-to-a-database).
### add whitelist ip to 0.0.0.0/0
![img_20.png](docs/img_20.png)
![img_21.png](docs/img_21.png)

# Step 2 env init
![img_22.png](docs/img_22.png)

```apt update && apt install git -y && apt install unzip -y && apt install docker-compose -y && apt install postgresql -y```
![img_23.png](docs/img_23.png)

# Step 3 install packages
```git clone https://github.com/daviddhc20120601/chat-with-pdf.git && cd chat-with-pdf/```
![img_24.png](docs/img_24.png)

# Step 4 run the docker
```cp .devops/Dockerfile . && docker build . -t haidonggpt/front:1.0 && docker run -d -p 8501:8501 haidonggpt/front:1.0```
![img_25.png](docs/img_25.png)

# Step 5 insert you token and start using
![img_26.png](docs/img_26.png)
## 5.1 chatgpt token:
[steps](https://help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key)
## 5.2 adbpg host name:gp-gs5inp2dl746742muo-master.gpdbmaster.singapore.rds.aliyuncs.com
![img_27.png](docs/img_27.png)
## 5.3 port: 5432
![img_28.png](docs/img_28.png)
## 5.4 database name: aigcpostgres
![img_29.png](docs/img_29.png)
## 5.5 adb pg username: aigcpostgres

## 5.6 adb pg password: alibabacloud666
# step 6 my token and credentials are invalidated and revoked,they are just a demo purpose to show you what are they look like. Do not try to use it , it is a waste of time
59 changes: 59 additions & 0 deletions README_legacy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Chat with PDF (or any other document)
# make sure your ADB is fastann enabled, CREATE EXTENSION IF NOT EXISTS fastann;
# if not as adbpf pdsa
![pdf chat-bot (preview)](docs/chat-bot.png)

This is still very much a work in progress, meaning it ain't production-ready
(and to be fair to myself, it was a good excuse to try out ChatGPT 😃).

## Usage
Make a copy of [.env.dev](.env.dev) file named `.env`,
and make sure all the **ENVIRONMENT_VARIABLES** are set - of importance,
the **OPENAI_API_KEY** must be present and set.

```bash
cp .env.dev .env # make a copy of .env.dev called .env
```

### Development (for now 😂)

Prerequisites:

- [Python](https://www.python.org/downloads/release/python-3112/)
- [Pipenv](https://pipenv.pypa.io/en/latest/)
- [Git](https://git-scm.com/)
- Obtain an [OpenAI API Key](https://platform.openai.com/account/api-keys)

With [Docker](https://www.docker.com/):

Make sure you have both [docker](https://www.docker.com/) and
[docker-compose](https://docs.docker.com/compose/) installed locally.

```bash
docker-compose -f .devops/docker-compose.yml up --build
````

Without [Docker](https://www.docker.com/):

```bash
$ git clone https://github.com/clovisphere/chat-with-pdf.git # clone the repo
$ cd chat-with-pdf # cd into project root
$ pipenv install # install dependencies
$ pipenv shell # activate virtualenv
$ python -m streamlit run app.py # or streamlit run app.py
```

If all went well, your app should be available on [http://127.0.0.1:8501](http://127.0.0.1:8501)


## Author

Clovis Mugaruka

- [github.com/clovisphere](https://github.com/clovisphere)
- [twitter/clovisphere](https://twitter.com/clovisphere)

## License

Copyright ©️ 2023, [Clovis Mugaruka](https://clovisphere.com).\
Released under the [MIT License](LICENSE).
9 changes: 7 additions & 2 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@


class Config:
# TITLE = """
# $\\left(\\Large{Chat with PDF 📃}\\right)$
# """
TITLE = """
$\\left(\\Large{Chat with PDF 📃}\\right)$
"""
$\\left(\\Large{Chat with PDF 📃}\\right)$
"""
ALLOW_MULTIPLE_FILES = False
ALLOWED_FILE_EXTENSION = 'pdf'
EXCERPT_LENGTH = 300
Expand All @@ -19,6 +22,8 @@ class Config:
HEIGHT = "60"




class DevelopmentConfig(Config):
pass

Expand Down
Binary file added docs/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_29.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img_5.png
Binary file added docs/img_6.png
Binary file added docs/img_7.png
Binary file added docs/img_8.png
Binary file added docs/img_9.png
19 changes: 19 additions & 0 deletions init.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash\n

rm -rf /etc/environmentadb \n
cat >> /etc/environmentadb << \"EOF\" \n
PG_HOST=${DBConnectString} \n
PG_PORT=5432 \n
PG_DATABASE=${DBMasterUserName} \n
PG_USER=${DBMasterUserName} \n
PG_PASSWORD=\"${DBMasterPassword}\"\n
\n

apt update && apt install git -y && apt install unzip -y && apt install docker-compose -y && apt install postgresql -y \n

git clone https://github.com/daviddhc20120601/chat-with-pdf.git && cd chat-with-pdf/ \n

cp .devops/Dockerfile . && docker build . -t haidonggpt/front:1.0 && docker run -d -e /etc/environmentadb -p 8501:8501 haidonggpt/front:1.0 \n



Loading