Knowledge Base AI Deployment and Construction - Unique Customer Service System Documentation Center

The only customer service system knowledge base service that supports personalized training ChatGPT in the form of vectors. This service is built independently. Here are some introductions

install docker

Now based on GPT to realize the self-built local knowledge base, the vector database is indispensable. Now I will introduce the installation of the qdrant vector database.

Because the qdrant vector database only supports docker deployment, install docker on the server. The following is to install docker under ubutnu

apt update
apt install apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install docker-ce docker-ce-cli containerd.io

If you use the pagoda panel, it will be easier and provide a visual interface for management

 Install vector database Qdrant

pull image

docker pull qdrant/qdrant

run service

docker run -d -p 6333:6333 qdrant/qdrant

 Deploy knowledge base service

The program file of the knowledge base service is shown in the figure below

The .env file is some configuration information, you can configure the key of openai or the domain name and proxy key of other third-party agents

OPENAI_KEY=api2d的key
OPENAI_API_BASE=https://openai.api2d.net
QDRANT_BASE=127.0.0.1
QDRANT_PORT=6333

 Start the service in daemon mode (Supervisor)

Install Supervisor

In general, the services we develop using golang, or services that listen to ports in other languages, do not have the function of a daemon process

Then we can use Supervisor to manage the process

Supervisor is a commonly used process management tool that can help you manage processes in your Linux system and ensure that they are always running in the background. Using Supervisor can realize automatic process restart, monitor process status, limit process resources and other functions, which is very suitable for service programs that need to run for a long time.

Here are some basic steps to use Supervisor under Linux:

Install Supervisor

In Linux systems, you can use package management tools to install Supervisor. For example, in Ubuntu systems, you can use the following commands to install:

apt-get install supervisor

Configure Supervisors

The configuration file of Supervisor is usually located in the /etc/supervisor/conf.d/ directory, you can create a configuration file with the suffix .conf in this directory, such as myprogram.conf, and then add the process to be managed in this file configuration information.

Here is the content of a sample configuration file:

[program:myprogram]
command=/usr/bin/python /path/to/myprogram.py
directory=/path/to/working/directory
user=myuser
autostart=true
autorestart=true
startretries=3
redirect_stderr=true
stdout_logfile=/var/log/myprogram.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10

This configuration file defines a process called myprogram

The command for this process is /usr/bin/python /path/to/myprogram.py

进程工作目录为/path/to/working/directory

运行该进程的用户为myuser

开启自动启动和自动重启功能,最多重启3次

将标准输出重定向到/var/log/myprogram.log文件中

最大文件大小为50MB

最多保留10个备份日志文件。

你可以根据自己的需要修改相应的配置信息。

启动Supervisor

配置完成后,你可以使用以下命令启动Supervisor服务:

service supervisor start

启动Supervisor后,它会自动加载配置文件并启动相应的进程。你可以使用以下命令来检查Supervisor服务状态:

service supervisor status

使用Supervisor管理进程

使用Supervisor管理进程非常简单,你可以使用以下命令对进程进行启动、停止、重启、查看状态等操作:

启动进程:

sudo supervisorctl start myprogram

停止进程:

sudo supervisorctl stop myprogram

重启进程:

sudo supervisorctl restart myprogram

查看进程状态:

supervisorctl status

如果配置完成后,使用supervisorctl start myprogram ,报错找不到进程,

那么可以尝试下面这条更新命令

supervisorctl update

如果配置正确会输出类似下面这样

myprogram : added process group

然后查看下进程状态

supervisorctl status

会看到

supervisor> status

myprogram                          RUNNING   pid 12345, uptime 1 day, 2:34:56

Guess you like

Origin blog.csdn.net/taoshihan/article/details/130676420