Browse Source

Merge pull request #1332 from zhayujie/feat-1.3.3

fix: reduce memory usage
master
zhayujie GitHub 1 year ago
parent
commit
41762a1c57
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 4 deletions
  1. +11
    -1
      README.md
  2. +2
    -2
      channel/wechat/wechat_channel.py
  3. +3
    -1
      docker/docker-compose.yml

+ 11
- 1
README.md View File

@@ -27,7 +27,7 @@ Demo made by [Visionn](https://www.wangpc.cc/)


# 更新日志 # 更新日志


>**2023.06.12:** 接入 [LinkAI](https://chat.link-ai.tech/console) 平台,可在线创建 个人知识库,并接入微信中。Beta版本欢迎体验,使用参考 [接入文档](https://link-ai.tech/platform/link-app/wechat)。
>**2023.06.12:** 接入 [LinkAI](https://chat.link-ai.tech/console) 平台,可在线创建 个人知识库,并接入微信、公众号及企业微信中。使用参考 [接入文档](https://link-ai.tech/platform/link-app/wechat)。


>**2023.04.26:** 支持企业微信应用号部署,兼容插件,并支持语音图片交互,私人助理理想选择,[使用文档](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/channel/wechatcom/README.md)。(contributed by [@lanvent](https://github.com/lanvent) in [#944](https://github.com/zhayujie/chatgpt-on-wechat/pull/944)) >**2023.04.26:** 支持企业微信应用号部署,兼容插件,并支持语音图片交互,私人助理理想选择,[使用文档](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/channel/wechatcom/README.md)。(contributed by [@lanvent](https://github.com/lanvent) in [#944](https://github.com/zhayujie/chatgpt-on-wechat/pull/944))


@@ -226,6 +226,16 @@ sudo docker compose up -d
sudo docker logs -f chatgpt-on-wechat sudo docker logs -f chatgpt-on-wechat
``` ```


#### (3) 插件使用

如果需要在docker容器中修改插件配置,可通过挂载的方式完成,将 [插件配置文件](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/plugins/config.json.template)
重命名为 `config.json`,放置于 `docker-compose.yml` 相同目录下,并在 `docker-compose.yml` 中的 `chatgpt-on-wechat` 部分下添加 `volumes` 映射:

```
volumes:
- ./config.json:/app/plugins/config.json
```

### 4. Railway部署 ### 4. Railway部署


> Railway 每月提供5刀和最多500小时的免费额度。 (07.11更新: 目前大部分账号已无法免费部署) > Railway 每月提供5刀和最多500小时的免费额度。 (07.11更新: 目前大部分账号已无法免费部署)


+ 2
- 2
channel/wechat/wechat_channel.py View File

@@ -53,7 +53,7 @@ def _check(func):
if msgId in self.receivedMsgs: if msgId in self.receivedMsgs:
logger.info("Wechat message {} already received, ignore".format(msgId)) logger.info("Wechat message {} already received, ignore".format(msgId))
return return
self.receivedMsgs[msgId] = cmsg
self.receivedMsgs[msgId] = True
create_time = cmsg.create_time # 消息时间戳 create_time = cmsg.create_time # 消息时间戳
if conf().get("hot_reload") == True and int(create_time) < int(time.time()) - 60: # 跳过1分钟前的历史消息 if conf().get("hot_reload") == True and int(create_time) < int(time.time()) - 60: # 跳过1分钟前的历史消息
logger.debug("[WX]history message {} skipped".format(msgId)) logger.debug("[WX]history message {} skipped".format(msgId))
@@ -105,7 +105,7 @@ class WechatChannel(ChatChannel):


def __init__(self): def __init__(self):
super().__init__() super().__init__()
self.receivedMsgs = ExpiredDict(60 * 60 * 24)
self.receivedMsgs = ExpiredDict(60 * 60)


def startup(self): def startup(self):
itchat.instance.receivingRetryCount = 600 # 修改断线超时时间 itchat.instance.receivingRetryCount = 600 # 修改断线超时时间


+ 3
- 1
docker/docker-compose.yml View File

@@ -3,10 +3,12 @@ services:
chatgpt-on-wechat: chatgpt-on-wechat:
image: zhayujie/chatgpt-on-wechat image: zhayujie/chatgpt-on-wechat
container_name: chatgpt-on-wechat container_name: chatgpt-on-wechat
security_opt:
- seccomp:unconfined
environment: environment:
OPEN_AI_API_KEY: 'YOUR API KEY' OPEN_AI_API_KEY: 'YOUR API KEY'
MODEL: 'gpt-3.5-turbo' MODEL: 'gpt-3.5-turbo'
OPEN_AI_PROXY: ''
PROXY: ''
SINGLE_CHAT_PREFIX: '["bot", "@bot"]' SINGLE_CHAT_PREFIX: '["bot", "@bot"]'
SINGLE_CHAT_REPLY_PREFIX: '"[bot] "' SINGLE_CHAT_REPLY_PREFIX: '"[bot] "'
GROUP_CHAT_PREFIX: '["@bot"]' GROUP_CHAT_PREFIX: '["@bot"]'


Loading…
Cancel
Save