lapis

lapis

理解以真实为本,但真实本身不会自动呈现

Feishu deploys ChatGPT robot.

Deploying Feishu ChatGPT Robot#

date: April 7, 2023
slug: 21
status: Published
tags: Technology
type: Post

Project open source link: Open Source Link

Robot Introduction and Functions#

FeishuX (GPT-3.5+DALL·E+Whisper), an intelligent office assistant.

Functions:#

  • 🗣 Voice communication: Private conversations with the robot
  • 💬 Multi-topic conversations: Support for private and group chat discussions, efficient and coherent
  • 🖼 Text to image: Support for text to image and image search
  • 🛖 Scene presets: Built-in rich scene list, one-click switch AI role
  • 🎭 Role-playing: Support for scene mode, adding discussion fun and creativity
  • 🔄 Context retention: Reply to the dialogue box to continue the same topic discussion
  • ⏰ Automatic ending: Dialogue automatically ends after timeout, supports clearing discussion history
  • 📝 Rich text cards: Support for rich text card replies, more informative and colorful information
  • 👍 Interactive feedback: Instantly obtain robot processing results
  • 🎰 Balance inquiry: Instantly obtain token consumption status
  • 🔙 History rollback: Easily rollback historical conversations and continue topic discussions 🚧
  • 🔒 Administrator mode: Built-in administrator mode for safer and more reliable use 🚧
  • 🌐 Multi-token load balancing: Optimize high-frequency calling scenarios at production level
  • ↩️ Support for reverse proxy: Provide faster and more stable access experience for users in different regions
  • 📚 Interact with Feishu documents: Become a super assistant for enterprise employees 🚧
  • 🎥 Instant conversion of topic content to PPT: Make your presentations simpler 🚧
  • 📊 Table analysis: Easily import Feishu tables to improve data analysis efficiency 🚧
  • 🍊 Private data training: Use company product information to train GPT for better personalized customer needs 🚧

Project Features#

  • 🍏 Dialogue based on OpenAI-gpt-3.5-turbo interface
  • 🍎 Access to Feishu and Feishu International through lark
  • 🥒 Support for deployment through Serverless cloud functions, local environments, Docker, binary installation packages, and other channels
  • 🍋 Based on goCache key-value pair cache

Deployment Tutorial#

Open Ai#

This step requires obtaining the Open Ai API, which has been discussed before and will not be repeated.

Project Deployment#

1. Docker Deployment#

docker run -d --restart=always --name feishu-chatgpt2 -p 9000:9000 -v /etc/localtime:/etc/localtim:ro  \
--env APP_ID=xxx \
--env APP_SECRET=xxx \
--env APP_ENCRYPT_KEY=xxx \
--env APP_VERIFICATION_TOKEN=xxx \
--env BOT_NAME=chatGpt \
--env OPENAI_KEY="sk-xxx1,sk-xxx2,sk-xxx3" \
--env API_URL=https://api.openai.com \
--env HTTP_PROXY="" \
dockerproxy.com/leizhenpeng/feishu-chatgpt:latest

Note

  • BOT_NAME is the name of the Feishu robot, for example, 韵酱的猫娘P60 E 青春探索版
  • OPENAI_KEY is the OpenAI key, multiple keys are separated by commas, for example, sk-xxx1,sk-xxx2,sk-xxx3
  • HTTP_PROXY is the proxy address of the host machine, for example, http://host.docker.internal:7890. If there is no proxy, it can be left unset.
  • API_URL is the OpenAI API interface address, for example, https://api.openai.com. If there is no reverse proxy, it can be left unset.

Event callback address: http://IP:9000/webhook/event Card callback address: http://IP:9000/webhook/card Fill in these addresses in the Feishu background later.

2. Docker Compose Deployment#

Edit docker-compose.yaml, configure the corresponding environment variables through the environment section (or mount the corresponding configuration file through volumes), and then run the following commands:

# Build the image
docker compose build

# Start the service
docker compose up -d

# Stop the service
docker compose down

Event callback address: http://IP:9000/webhook/event Card callback address: http://IP:9000/webhook/card

3. Deploying with Railway#

Simply configure the environment variables and deploy according to the instructions provided in the open source project address. I'm too lazy to write it out.

Railway is a foreign Serverless platform that supports multiple languages. It can deploy code repositories from Github to the Railway platform with one click, and then configure environment variables on the Railway platform.

This project also supports local deployment, serverless cloud function deployment, and binary installation package deployment, but I think Docker is convenient and sufficient.

Feishu Robot Configuration#

Summary: Fill in the callback address in the "Event Subscription" section of the Feishu robot background, and fill in the message card request URL in the "Robot" section. Finally, set the permissions for the robot.

1. Go to the developer platform to create an application and obtain the APPID and Secret#

2. Go to Application Functions - Robot and create a robot#

3. Specific configuration#

Event Subscription Obtain the public network address from cpolar, serverless, or Railway, and fill it in the "Event Subscription" section of the Feishu robot background. For example, http://xxxx.r6.cpolar.top is the public network address exposed by cpolar, /webhook/event is the unified application route, and the final callback address is http://xxxx.r6.cpolar.top/webhook/event

Card Message In the "Robot" section of the Feishu robot background, fill in the message card request URL. For example, http://xxxx.r6.cpolar.top is the public network address exposed by cpolar, /webhook/card is the unified application route, and the final message card request URL is http://xxxx.r6.cpolar.top/webhook/card

Robot Permissions In the "Event Subscription" section, search for the three words "Robot Join Group", "Receive Messages", "Message Read", and check all the permissions behind them. Go to the permission management page, search for images, and check "Get and upload image or file resources". Finally, the following callback events will be added:

  • im (Get and upload image or file resources)
  • im
  • im.group_at_msg (Get all messages in the group)
  • im.group_at_msg (Receive messages with @robot in group chat)
  • im.p2p_msg (Get user-to-robot private chat messages)
  • im.p2p_msg (Read user-to-robot private chat messages)
  • im:message (Get messages where users @robot in the group)
  • im:chat (Get group information)
  • im (Get and update group information)

Release#

After configuring the robot, publish the robot and wait for administrator approval.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.