Skip to content

VitalPBX/vitalpbx_ai_support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VitalPBX - AI Support with ChatGPT

Necessary Resources

OpenAI Account (https://platform.openai.com/apps).
Postfix for sending emails
Python, for ChatGPT query service
PHP 8
Chroma database
MariaDB 10
Apache

Installing dependencies

  apt update
  apt install python3 python3-pip
  pip install websocket-client
  pip install asyncio
  wget https://github.com/VitalPBX/vitalpbx_ai_support/main/requirements.txt
  pip install -r requirements.txt

Email configuration

This example is made to work with Postfix, so we recommend you configure it correctly before proceeding.

Install Postfix

  sudo apt install postfix

Install Database

  wget https://github.com/VitalPBX/vitalpbx_ai_support/main/vpbx_agentai.sql
  mysql -u root -e  "CREATE DATABASE vpbx_agentai;"
  mysql -u root vpbx_agentai < vpbx_agentai.sql

Create User

  mysql -u root
  GRANT ALL PRIVILEGES ON vpbx_agentai.* TO myuser@'localhost' IDENTIFIED BY 'mypassword';
  FLUSH PRIVILEGES;
  exit;

Install from script

Download the script

  wget https://github.com/VitalPBX/vitalpbx_ai_support/main/install.sh

Give execution permissions

  chmod +x install.sh

Run the script

  ./install.sh

Edit .env, database.php,vpbxaisupport.py and embededded-docs.py

Now we are going to edit the .env file to add the Openai API Key and the paths to the documents and the ChromaDB database.

  cd /usr/share/vpbx_ai_support/
  nano .env

Later we are going to edit the database.php file to configure the access credentials to the amriadb database

  cd /var/www/vpbx_ai_support/html/
  nano dtabase.php

In vpbxaisupport.py change the route of valid certificate

    ssl_cert = "/usr/share/PathToCertificate/bundle.pem"
    ssl_key = "/usr/share/PathToCertificate/private.pem"

Embedding Document

To transfer our documents to the ChromaDB database we must do the following:
1.- Upload the document to the /usr/share/vpbx_ai_support/docs folder with the information to use for the query with ChatGPT-Embedded
2.- To transfer this document to a Vector database (ChromaDB), proceed to execute the following command.

  cd /usr/share/vpbx_ai_support/
  ./embedded-docs.py

Create apache configuration file

Remember to create the Apache configuration file to access the web site (/etc/apache2/sites-available).
We can see an example of the configuration in the following file:
mysite.com.conf

Note

Remember to unblock port 3002 or the one you decided to use in the VitalPBx firewall as in any other firewall that VitalPBX has in front of you.
To make sure everything is fine, we can run the following command.

  netstat -tuln | grep 3002

And it would have to return the following to us:

tcp        0      0 192.168.57.50:3002       0.0.0.0:*               LISTEN     
tcp        0      0 127.0.1.1:3002           0.0.0.0:*               LISTEN  

192.168.57.50 is our public or private IP.