Python3 + Postgresql14 with brew

The over all setting should be listed below:

Python3 + Postgresql14 + pgvector plugin

Here are some links for installing and setting the ‘brew’ tool and Postgresql database. After installing the ‘brew’ tool and Postgresql database, 70% of the tasks should have been done. 🙂

-> How to install Brew on Ubuntu 20.04 LTS Linux;

-> How To Install PostgreSQL on Ubuntu 20.04;

-> Uninstall Postgresql database on Linux;

In the repository, the database connection is configured at file /gpt/config.json, please use ‘api’ mode if we want to be a service. ‘console’ mode is acceptable when debugging. The ‘open_ai_key’ is the token from OpenAI. The ‘postgres_url’ is the database connection, while 5432 is the default port and ‘mygpt’ is the database name.
Please use some Postgresql command to create the database, then install and activate the pgvector plugin. May use ‘\l’ and ‘\dx’ commands to check the current database and plugin status.


I suggest using ‘brew’ tool to install all the software and service on OSX or Linux. We have different ways to install the ‘brew’ tools that can be found on google. Below, will list some critical commands for installing.

Use ‘brew’ tool to install python3 with pip tool. Normally, pip should be installed by default. 

brew install python@3
brew install pip

Install postgresql vector plugin

brew install postgresql@14
brew install pgvector

Initialize database

 – initdb ~/postgres/

 – psql postgres

 – # \l

 – # \c chatgpt

 – # \dx

Install pm2

 : use npm or other command are acceptable. or can use other containers;

install ngrok (optional)


Some commands may need:

pg_ctl -V

pg_ctl -D /home/chatgptm/postgres/ -l logfile start

pg_ctl -D /home/chatgptm/postgres -l /home/chatgptm/postgres/serverlog.status

pg_ctl -D /home/chatgptm/postgres -l /home/chatgptm/postgres/serverlog.status

pg_ctl -D /home/chatgptm/postgres/ -l logfile start

ngrok http 9533 -log=stdout > ngrok.log &
ngrok http 9533 > ~/ngrok.log &