Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes baiducloud bug and partial code formatting (Sourcery refactored) #984

Merged
merged 3 commits into from
Jun 25, 2023

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Jun 24, 2023

Pull Request #983 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/lss233/chatgpt-mirai-qq-bot pull/983/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from Haibersut June 24, 2023 12:51
Comment on lines -168 to +189
self.config.response.default_ai = 'chatgpt-web'
elif len(self.bots['openai-api']) > 0:
self.config.response.default_ai = 'chatgpt-api'
elif len(self.bots['bing-cookie']) > 0:
self.config.response.default_ai = 'bing'
elif len(self.bots['bard-cookie']) > 0:
self.config.response.default_ai = 'bard'
elif len(self.bots['yiyan-cookie']) > 0:
self.config.response.default_ai = 'yiyan'
elif len(self.bots['chatglm-api']) > 0:
self.config.response.default_ai = 'chatglm-api'
elif len(self.bots['xinghuo-cookie']) > 0:
self.config.response.default_ai = 'xinghuo'
elif len(self.bots['slack-accesstoken']) > 0:
self.config.response.default_ai = 'slack-claude'
else:
self.config.response.default_ai = 'chatgpt-web'
# 自动推测默认 AI
default_ai_mappings = {
"poe-web": "poe-chatgpt",
"slack-accesstoken": "slack-claude",
"chatgpt-web": "chatgpt-web",
"openai-api": "chatgpt-api",
"bing-cookie": "bing",
"bard-cookie": "bard",
"yiyan-cookie": "yiyan",
"chatglm-api": "chatglm-api",
"xinghuo-cookie": "xinghuo",
}

self.config.response.default_ai = next(
(
default_ai
for key, default_ai in default_ai_mappings.items()
if len(self.bots[key]) > 0
),
'chatgpt-web',
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function BotManager.login refactored with the following changes:

  • Move assignments closer to their usage (move-assign)
  • Use the built-in function next instead of a for-loop (use-next)

@Haibersut Haibersut merged commit 71e9647 into browser-version Jun 25, 2023
@Haibersut Haibersut deleted the sourcery/pull-983 branch June 25, 2023 03:09
@liu2-3zhi
Copy link
Contributor

liu2-3zhi commented Jun 26, 2023

详情见
https://github.com/lss233/chatgpt-mirai-qq-bot/issues/862#issuecomment-1605256760

漏洞依然没有被修复

仍然无法调用百度云文本审核

image
874d26f2eac5a5af7d2eb6b9205c339

以下是控制台输出信息

chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.648 | DEBUG    | adapter.chatgpt.api:ask:103 - [ChatGPT-API:gpt-3.5-turbo] 响应:你好啊,有什么可以帮到你的吗?
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.649 | DEBUG    | adapter.chatgpt.api:ask:104 - 使用 token 数:68
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | ERROR    | middlewares.baiducloud:handle_respond:121 - [百度云文本审核] 其他错误:'conclusion'
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | DEBUG    | platforms.onebot_bot:respond:112 - [OneBot] 尝试发送消息:[百度云文本审核] 判定出错
chatgpt-qq-chatgpt-1     | 以下是原消息:

以下是配置信息

[baiducloud]
# 是否启动百度云内容安全审核
# 注册地址: http://console.bce.baidu.com/ai/#/ai/antiporn/overview/index
check = true

# 百度云API_KEY 24位英文数字字符串
baidu_api_key = "手动打码"

# 百度云SECRET_KEY 32位的英文数字字符串
baidu_secret_key ="手动打码"

# 不合规消息自定义返回
illgalmessage = "[百度云]请珍惜机器人,当前返回内容不合规"

@Haibersut
Copy link
Collaborator

详情见 https://github.com/lss233/chatgpt-mirai-qq-bot/issues/862#issuecomment-1605256760

漏洞依然没有被修复

仍然无法调用百度云文本审核

image 874d26f2eac5a5af7d2eb6b9205c339

以下是控制台输出信息

chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.648 | DEBUG    | adapter.chatgpt.api:ask:103 - [ChatGPT-API:gpt-3.5-turbo] 响应:你好啊,有什么可以帮到你的吗?
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.649 | DEBUG    | adapter.chatgpt.api:ask:104 - 使用 token 数:68
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | ERROR    | middlewares.baiducloud:handle_respond:121 - [百度云文本审核] 其他错误:'conclusion'
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | DEBUG    | platforms.onebot_bot:respond:112 - [OneBot] 尝试发送消息:[百度云文本审核] 判定出错
chatgpt-qq-chatgpt-1     | 以下是原消息:

以下是配置信息

[baiducloud]
# 是否启动百度云内容安全审核
# 注册地址: http://console.bce.baidu.com/ai/#/ai/antiporn/overview/index
check = true

# 百度云API_KEY 24位英文数字字符串
baidu_api_key = "手动打码"

# 百度云SECRET_KEY 32位的英文数字字符串
baidu_secret_key ="手动打码"

# 不合规消息自定义返回
illgalmessage = "[百度云]请珍惜机器人,当前返回内容不合规"

出错了就肯定不会有审核

@liu2-3zhi
Copy link
Contributor

详情见 https://github.com/lss233/chatgpt-mirai-qq-bot/issues/862#issuecomment-1605256760

漏洞依然没有被修复

仍然无法调用百度云文本审核

image 874d26f2eac5a5af7d2eb6b9205c339

以下是控制台输出信息

chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.648 | DEBUG    | adapter.chatgpt.api:ask:103 - [ChatGPT-API:gpt-3.5-turbo] 响应:你好啊,有什么可以帮到你的吗?
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.649 | DEBUG    | adapter.chatgpt.api:ask:104 - 使用 token 数:68
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | ERROR    | middlewares.baiducloud:handle_respond:121 - [百度云文本审核] 其他错误:'conclusion'
chatgpt-qq-chatgpt-1     | 2023-06-26 05:59:14.821 | DEBUG    | platforms.onebot_bot:respond:112 - [OneBot] 尝试发送消息:[百度云文本审核] 判定出错
chatgpt-qq-chatgpt-1     | 以下是原消息:

以下是配置信息

[baiducloud]
# 是否启动百度云内容安全审核
# 注册地址: http://console.bce.baidu.com/ai/#/ai/antiporn/overview/index
check = true

# 百度云API_KEY 24位英文数字字符串
baidu_api_key = "手动打码"

# 百度云SECRET_KEY 32位的英文数字字符串
baidu_secret_key ="手动打码"

# 不合规消息自定义返回
illgalmessage = "[百度云]请珍惜机器人,当前返回内容不合规"

出错了就肯定不会有审核

所以错误仍然未被修复!

@Haibersut
Copy link
Collaborator

这个是你账户的问题,不是我们这边的问题,百度云审核导致的程序出错已经被正常的修复

@liu2-3zhi
Copy link
Contributor

经过核查发现是账号余额不足,现在可以正常调用了。希望可以完善错误提示。
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants