mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-05-22 04:31:51 +08:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2133c1d6af | |||
| 0bf06ddfd3 | |||
| 024a50d642 | |||
| e4eebd64d1 | |||
| c9055989e9 | |||
| 4f1ed197ce | |||
| 3e710aa2a1 | |||
| b6226a45bb | |||
| 3001ba9266 | |||
| b0a401a1ed | |||
| 6b4dc37428 |
@@ -158,9 +158,8 @@ class AzureChatGPTBot(ChatGPTBot):
|
||||
self.args["deployment_id"] = conf().get("azure_deployment_id")
|
||||
|
||||
def create_img(self, query, retry_count=0, api_key=None):
|
||||
api_base = "https://a-wxf.openai.azure.com/"
|
||||
api_version = "2022-08-03-preview"
|
||||
url = "{}dalle/text-to-image?api-version={}".format(api_base, api_version)
|
||||
url = "{}dalle/text-to-image?api-version={}".format(openai.api_base, api_version)
|
||||
api_key = api_key or openai.api_key
|
||||
headers = {"api-key": api_key, "Content-Type": "application/json"}
|
||||
try:
|
||||
@@ -175,7 +174,7 @@ class AzureChatGPTBot(ChatGPTBot):
|
||||
time.sleep(int(retry_after))
|
||||
response = requests.get(operation_location, headers=headers)
|
||||
status = response.json()["status"]
|
||||
image_url = response.json()["result"]["contentUrl"]
|
||||
image_url = response.json()["result"]["contentUrl"]
|
||||
return True, image_url
|
||||
except Exception as e:
|
||||
logger.error("create image error: {}".format(e))
|
||||
|
||||
@@ -74,7 +74,7 @@ Error code: 60020, message: "not allow to access from your ip, ...from ip: xx.xx
|
||||
|
||||
### Railway部署方式
|
||||
|
||||
公众号不能在`Railway`上部署,但企业微信应用可以!
|
||||
公众号不能在`Railway`上部署,但企业微信应用[可以](https://railway.app/template/-FHS--?referralCode=RC3znh)!
|
||||
|
||||
[](https://railway.app/template/-FHS--?referralCode=RC3znh)
|
||||
|
||||
@@ -84,4 +84,4 @@ Error code: 60020, message: "not allow to access from your ip, ...from ip: xx.xx
|
||||
|
||||
AIGC开放社区中已经部署了多个可免费使用的Bot,扫描下方的二维码会自动邀请你来体验。
|
||||
|
||||
<img width="200" src="../../docs/images/aigcopen.png">
|
||||
<img width="200" src="../../docs/images/aigcopen.png">
|
||||
|
||||
@@ -93,7 +93,8 @@ class WechatComAppChannel(ChatChannel):
|
||||
image_storage = io.BytesIO()
|
||||
for block in pic_res.iter_content(1024):
|
||||
image_storage.write(block)
|
||||
if (sz := fsize(image_storage)) >= 10 * 1024 * 1024:
|
||||
sz = fsize(image_storage)
|
||||
if sz >= 10 * 1024 * 1024:
|
||||
logger.info("[wechatcom] image too large, ready to compress, sz={}".format(sz))
|
||||
image_storage = compress_imgfile(image_storage, 10 * 1024 * 1024 - 1)
|
||||
logger.info("[wechatcom] image compressed, sz={}".format(fsize(image_storage)))
|
||||
@@ -109,7 +110,8 @@ class WechatComAppChannel(ChatChannel):
|
||||
logger.info("[wechatcom] sendImage url={}, receiver={}".format(img_url, receiver))
|
||||
elif reply.type == ReplyType.IMAGE: # 从文件读取图片
|
||||
image_storage = reply.content
|
||||
if (sz := fsize(image_storage)) >= 10 * 1024 * 1024:
|
||||
sz = fsize(image_storage)
|
||||
if sz >= 10 * 1024 * 1024:
|
||||
logger.info("[wechatcom] image too large, ready to compress, sz={}".format(sz))
|
||||
image_storage = compress_imgfile(image_storage, 10 * 1024 * 1024 - 1)
|
||||
logger.info("[wechatcom] image compressed, sz={}".format(fsize(image_storage)))
|
||||
|
||||
@@ -4,7 +4,7 @@ import time
|
||||
import web
|
||||
from wechatpy import parse_message
|
||||
from wechatpy.replies import ImageReply, VoiceReply, create_reply
|
||||
|
||||
import textwrap
|
||||
from bridge.context import *
|
||||
from bridge.reply import *
|
||||
from channel.wechatmp.common import *
|
||||
|
||||
@@ -26,4 +26,4 @@ RUN chmod +x /entrypoint.sh \
|
||||
|
||||
USER noroot
|
||||
|
||||
ENTRYPOINT ["docker/entrypoint.sh"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -31,9 +31,10 @@ WORKDIR ${BUILD_PREFIX}
|
||||
ADD ./entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN chmod +x /entrypoint.sh \
|
||||
&& mkdir -p /home/noroot \
|
||||
&& groupadd -r noroot \
|
||||
&& useradd -r -g noroot -s /bin/bash -d /home/noroot noroot \
|
||||
&& chown -R noroot:noroot ${BUILD_PREFIX}
|
||||
&& chown -R noroot:noroot /home/noroot ${BUILD_PREFIX}
|
||||
|
||||
USER noroot
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ WORKDIR ${BUILD_PREFIX}
|
||||
ADD docker/entrypoint.sh /entrypoint.sh
|
||||
|
||||
RUN chmod +x /entrypoint.sh \
|
||||
&& mkdir -p /home/noroot \
|
||||
&& groupadd -r noroot \
|
||||
&& useradd -r -g noroot -s /bin/bash -d /home/noroot noroot \
|
||||
&& chown -R noroot:noroot ${BUILD_PREFIX}
|
||||
&& chown -R noroot:noroot /home/noroot ${BUILD_PREFIX}
|
||||
|
||||
USER noroot
|
||||
|
||||
ENTRYPOINT ["docker/entrypoint.sh"]
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
@@ -25,8 +25,9 @@ def auto_login(self, hotReload=False, statusStorageDir='itchat.pkl',
|
||||
self.useHotReload = hotReload
|
||||
self.hotReloadDir = statusStorageDir
|
||||
if hotReload:
|
||||
if rval:=self.load_login_status(statusStorageDir,
|
||||
loginCallback=loginCallback, exitCallback=exitCallback):
|
||||
rval=self.load_login_status(statusStorageDir,
|
||||
loginCallback=loginCallback, exitCallback=exitCallback)
|
||||
if rval:
|
||||
return
|
||||
logger.error('Hot reload failed, logging in normally, error={}'.format(rval))
|
||||
self.logout()
|
||||
|
||||
@@ -123,7 +123,7 @@ class PluginManager:
|
||||
try:
|
||||
instance = plugincls()
|
||||
except Exception as e:
|
||||
logger.error("Failed to init %s, diabled. %s" % (name, e))
|
||||
logger.exception("Failed to init %s, diabled. %s" % (name, e))
|
||||
self.disable_plugin(name)
|
||||
failed_plugins.append(name)
|
||||
continue
|
||||
|
||||
@@ -31,7 +31,8 @@ class BaiduTranslator(Translator):
|
||||
while retry_cnt:
|
||||
r = requests.post(self.url, params=payload, headers=headers)
|
||||
result = r.json()
|
||||
if errcode := result.get("error_code", "52000") != "52000":
|
||||
errcode = result.get("error_code", "52000")
|
||||
if errcode != "52000":
|
||||
if errcode == "52001" or errcode == "52002":
|
||||
retry_cnt -= 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user