芝士就是菜

芝士就是菜

公众号 芝士就是菜
zhihu
bilibili
youtube
twitter
github
email

Introduction to Lobechat Chatbot and Docker Deployment (Attention: There are pitfalls to be aware of)

image.png

1 Introduction to LobeChat#

Official Introduction: LobeChat is an open-source, high-performance chatbot framework. It supports speech synthesis, multimodality, and an extensible plugin system. It supports one-click free deployment of private ChatGPT/LLM web applications.

There is detailed documentation on github-lobe-chat🤖 of lobechat (both in Chinese and English) and it has a Discord community. This thing is like deploying your own private chatgpt service. So why don't I just use chatgpt directly and choose to deploy and use lobechat? The documentation provides the following advantages:

  1. GPT Visual Perception
  2. TTS & STT Voice Conversation
  3. Text to Image Generation
  4. Function Calling Plugin System
  5. Assistant Market
  6. PWA Progressive Web Application
  7. Mobile Device Adaptation
  8. Custom Themes

For me, there are two aspects that attract me. The first one is its plugin system, which has a very rich plugin market. For me, it is quite convenient to install some academic and search-related plugins for daily use.

image.png

Of course, the second point that attracts me is that there are a lot of preset assistants, covering various aspects, which can greatly reduce the difficulty of thinking about prompt words and related matters.

image.png

I installed several assistants below, and the tarot reader assistant here is quite interesting.

image.png

Of course, there is another reason for choosing this framework, which is that the deployment is particularly simple. Just a few lines of commands with Docker, and the official documentation is very detailed (but if you use third-party API services, there are still some things to pay attention to, which will be discussed below).

lobe-chat Chinese documentation

2 Deploying LobeChat using Docker#

LobeChat provides a self-hosted version of Vercel and a Docker image, which allows you to deploy your own chatbot in minutes without any programming knowledge. Here, we mainly discuss how to deploy using Docker.

2.1 Using the Official API#

If you are using the official OpenAI API, you only need to fill in an API key, which means replacing sk-xxxx with your own key. Find API keys in the OpenAI API official website, then create and copy it. Then run the following command in the terminal:

docker run -d -p 3210:3210 \
  -e OPENAI_API_KEY=sk-xxxx \
  -e ACCESS_CODE=lobe66 \
  --name lobe-chat \
  lobehub/lobe-chat

Note that in the above command, both the ACCESS_CODE and name options can be customized. The first one is the password (you need to enter the password when using it), and the second one is the name of the service.

2.2 Using a Third-Party API#

Using a third-party API can be a bit tricky, and if not done properly, the deployment may fail. I used the AIGC-API third-party API, which is compatible with various mainstream AIs, supports GPT-4 Turbo, DALL·E, and other OpenAI models, as well as a large number of AI applications and frameworks. The price is relatively cheap, and the key point is that you can pay with Alipay and other methods. Recharging with the official OpenAI API is expensive, and the difficulty of recharging is too high.

docker run -d -p 3210:3210 \
  -e OPENAI_API_KEY=sk-xxxx \
  -e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
  -e ACCESS_CODE=lobe66 \
  --name lobe-chat \
  lobehub/lobe-chat

Replace https://api-proxy.com with the URL of the third-party service. If you want to use the AIGC API, replace it with: https://api.aigcapi.io. Be careful not to miss the v1 option. Fill in the OPENAI_API_KEY option with the key value of the AIGC token, and then run the above command in the terminal.

If you don't replace OPENAI_PROXY_URL, the deployment will fail. If you miss v1, there will be abnormal replies, and all the replies will be blank, as shown in the figure below.

image.png

3 Upgrading LobeChat#

The LobeChat project is quite popular and has frequent updates. The update process is also very simple.

  1. Stop and remove the currently running LobeChat container:
docker stop lobe-chat
docker rm lobe-chat
  1. Pull the latest Docker image of LobeChat:
docker pull lobehub/lobe-chat
  1. Redeploy using the newly pulled Docker image:
docker run -d -p 3210:3210 \
  -e OPENAI_API_KEY=sk-xxxx \
  -e OPENAI_PROXY_URL=https://api-proxy.com/v1 \
  -e ACCESS_CODE=lobe66 \
  --name lobe-chat \
  lobehub/lobe-chat
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.