Browse Source

Merge pull request #451 from limccn/feature/docker-support-voice-recognition

feat: container support speech recognition
master
zhayujie GitHub 1 year ago
parent
commit
54290f7e5d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions
  1. +1
    -0
      docker/docker-compose.yaml
  2. +16
    -11
      docker/entrypoint.sh
  3. +1
    -0
      docker/sample-chatgpt-on-wechat/.env

+ 1
- 0
docker/docker-compose.yaml View File

@@ -15,5 +15,6 @@ services:
GROUP_NAME_WHITE_LIST: '["ChatGPT测试群", "ChatGPT测试群2"]' GROUP_NAME_WHITE_LIST: '["ChatGPT测试群", "ChatGPT测试群2"]'
IMAGE_CREATE_PREFIX: '["画", "看", "找"]' IMAGE_CREATE_PREFIX: '["画", "看", "找"]'
CONVERSATION_MAX_TOKENS: 1000 CONVERSATION_MAX_TOKENS: 1000
SPEECH_RECOGNITION: 'false'
CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。' CHARACTER_DESC: '你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。'
EXPIRES_IN_SECONDS: 3600 EXPIRES_IN_SECONDS: 3600

+ 16
- 11
docker/entrypoint.sh View File

@@ -16,6 +16,7 @@ GROUP_CHAT_PREFIX=${GROUP_CHAT_PREFIX:-""}
GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-""} GROUP_NAME_WHITE_LIST=${GROUP_NAME_WHITE_LIST:-""}
IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-""} IMAGE_CREATE_PREFIX=${IMAGE_CREATE_PREFIX:-""}
CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-""} CONVERSATION_MAX_TOKENS=${CONVERSATION_MAX_TOKENS:-""}
SPEECH_RECOGNITION=${SPEECH_RECOGNITION:-""}
CHARACTER_DESC=${CHARACTER_DESC:-""} CHARACTER_DESC=${CHARACTER_DESC:-""}
EXPIRES_IN_SECONDS=${EXPIRES_IN_SECONDS:-""} EXPIRES_IN_SECONDS=${EXPIRES_IN_SECONDS:-""}


@@ -36,50 +37,54 @@ fi


# modify content in config.json # modify content in config.json
if [ "$OPEN_AI_API_KEY" != "" ] ; then if [ "$OPEN_AI_API_KEY" != "" ] ; then
sed -i "2c \"open_ai_api_key\": \"$OPEN_AI_API_KEY\"," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"open_ai_api_key\".*,$/\"open_ai_api_key\": \"$OPEN_AI_API_KEY\",/" $CHATGPT_ON_WECHAT_CONFIG_PATH
else else
echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m" echo -e "\033[31m[Warning] You need to set OPEN_AI_API_KEY before running!\033[0m"
fi fi


# use http_proxy as default # use http_proxy as default
if [ "$HTTP_PROXY" != "" ] ; then if [ "$HTTP_PROXY" != "" ] ; then
sed -i "3c \"proxy\": \"$HTTP_PROXY\"," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"proxy\".*,$/\"proxy\": \"$HTTP_PROXY\",/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$OPEN_AI_PROXY" != "" ] ; then if [ "$OPEN_AI_PROXY" != "" ] ; then
sed -i "3c \"proxy\": \"$OPEN_AI_PROXY\"," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"proxy\".*,$/\"proxy\": \"$OPEN_AI_PROXY\",/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$SINGLE_CHAT_PREFIX" != "" ] ; then if [ "$SINGLE_CHAT_PREFIX" != "" ] ; then
sed -i "4c \"single_chat_prefix\": $SINGLE_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"single_chat_prefix\".*,$/\"single_chat_prefix\": $SINGLE_CHAT_PREFIX,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$SINGLE_CHAT_REPLY_PREFIX" != "" ] ; then if [ "$SINGLE_CHAT_REPLY_PREFIX" != "" ] ; then
sed -i "5c \"single_chat_reply_prefix\": $SINGLE_CHAT_REPLY_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"single_chat_reply_prefix\".*,$/\"single_chat_reply_prefix\": $SINGLE_CHAT_REPLY_PREFIX,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$GROUP_CHAT_PREFIX" != "" ] ; then if [ "$GROUP_CHAT_PREFIX" != "" ] ; then
sed -i "6c \"group_chat_prefix\": $GROUP_CHAT_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"group_chat_prefix\".*,$/\"group_chat_prefix\": $GROUP_CHAT_PREFIX,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$GROUP_NAME_WHITE_LIST" != "" ] ; then if [ "$GROUP_NAME_WHITE_LIST" != "" ] ; then
sed -i "7c \"group_name_white_list\": $GROUP_NAME_WHITE_LIST," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"group_name_white_list\".*,$/\"group_name_white_list\": $GROUP_NAME_WHITE_LIST,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$IMAGE_CREATE_PREFIX" != "" ] ; then if [ "$IMAGE_CREATE_PREFIX" != "" ] ; then
sed -i "8c \"image_create_prefix\": $IMAGE_CREATE_PREFIX," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"image_create_prefix\".*,$/\"image_create_prefix\": $IMAGE_CREATE_PREFIX,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$CONVERSATION_MAX_TOKENS" != "" ] ; then if [ "$CONVERSATION_MAX_TOKENS" != "" ] ; then
sed -i "9c \"conversation_max_tokens\": $CONVERSATION_MAX_TOKENS," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"conversation_max_tokens\".*,$/\"conversation_max_tokens\": $CONVERSATION_MAX_TOKENS,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi

if [ "$SPEECH_RECOGNITION" != "" ] ; then
sed -i "s/\"speech_recognition\".*,$/\"speech_recognition\": $SPEECH_RECOGNITION,/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$CHARACTER_DESC" != "" ] ; then if [ "$CHARACTER_DESC" != "" ] ; then
sed -i "10c \"character_desc\": \"$CHARACTER_DESC\"," $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"character_desc\".*,$/\"character_desc\": \"$CHARACTER_DESC\",/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


if [ "$EXPIRES_IN_SECONDS" != "" ] ; then if [ "$EXPIRES_IN_SECONDS" != "" ] ; then
sed -i "11c \"expires_in_seconds\": $EXPIRES_IN_SECONDS" $CHATGPT_ON_WECHAT_CONFIG_PATH
sed -i "s/\"expires_in_seconds\".*$/\"expires_in_seconds\": $EXPIRES_IN_SECONDS/" $CHATGPT_ON_WECHAT_CONFIG_PATH
fi fi


# go to prefix dir # go to prefix dir


+ 1
- 0
docker/sample-chatgpt-on-wechat/.env View File

@@ -6,6 +6,7 @@ GROUP_CHAT_PREFIX=["@bot"]
GROUP_NAME_WHITE_LIST=["ChatGPT测试群", "ChatGPT测试群2"] GROUP_NAME_WHITE_LIST=["ChatGPT测试群", "ChatGPT测试群2"]
IMAGE_CREATE_PREFIX=["画", "看", "找"] IMAGE_CREATE_PREFIX=["画", "看", "找"]
CONVERSATION_MAX_TOKENS=1000 CONVERSATION_MAX_TOKENS=1000
SPEECH_RECOGNITION=false
CHARACTER_DESC=你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。 CHARACTER_DESC=你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。
EXPIRES_IN_SECONDS=3600 EXPIRES_IN_SECONDS=3600




Loading…
Cancel
Save