Code Monkey home page Code Monkey logo

zhayujie / bot-on-anything Goto Github PK

View Code? Open in Web Editor NEW
3.8K 3.8K 889.0 722 KB

Connect AI models (like ChatGPT-3.5/4.0, Baidu Yiyan, New Bing, Bard) to apps (like Wechat, public account, DingTalk, Telegram, QQ). 将 ChatGPT、必应、文心一言、谷歌Bard 等对话模型连接各类应用,如微信、公众号、QQ、Telegram、Gmail、Slack、Web、企业微信、飞书、钉钉等。

License: MIT License

Python 81.29% CSS 7.54% JavaScript 5.08% HTML 4.61% Shell 1.40% Dockerfile 0.09%
chatgpt gmail qq slack telegram web wechat wechat-official-account

bot-on-anything's Introduction

bot-on-anything's People

Contributors

6vision avatar amaoo avatar an-anthony avatar dbink avatar fan-yu-feng avatar ffwen123 avatar jokereven avatar lichengzhe avatar mouyong avatar oldcai avatar onewhitethreee avatar regimenarsenic avatar selierlin avatar tercel avatar unkoe avatar vectorsss avatar winse avatar winspain avatar wujiyu115 avatar zhayujie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bot-on-anything's Issues

解决国内不能使用OpenAI问题的思路

这里不想谈代理,但有一个思路供参考,希望抛砖引玉。
再增加一个channel, 比如network。实现时分成client和server两部分且分别运行在两个计算机上,比如分别在国内和美国。Client只提供一个简单的对话界面,后台与美国的一个server联系。Server运行时可以有两种模式:private和public,前者类似于现在的terminal,自成一体,不提供共享服务;后者除了terminal功能,另外再提供共享接口给国内的clients,并中转它们的queries to ChatGPT服务。目的是把国内的queries包装成国外的,且中转ChatGPT的responses back to clients。这是利用community的支持解决国内使用OpenAI的问题。至于如何实现“提供接口给国内”,有多种方式且应本着自愿的原则。比如,让QQ的客户端与服务端分别运行在两个计算机上,其中服务端在美国;或者另外开发一种通信方式。

遇到两个问题

1, 用terminal,可以看见对话提示,并输入问题。总是得到如下回答,说我quota用完了,实际上我是首次使用。新生成了一个API_Key也是一样。
Please input your question
User:
Hello
Bot:
[WARNING][2023-02-26 15:12:52][log.py:39] - You exceeded your current quota, please check your plan and billing details.
[WARNING][2023-02-26 15:12:57][log.py:39] - [OPEN_AI] RateLimit exceed, 第1次重试
[WARNING][2023-02-26 15:12:58][log.py:39] - You exceeded your current quota, please check your plan and billing details.

2, 用wechat,可以看见二维码,微信扫码后总是说:Network disconnected. Try again later.

请问这两个分别是什么问题?多谢!

TG运行问题

halo,大佬,我想请教下如果像tggmail这些是不是一定要放在有外网的服务器上运行,如果我想在本地电脑开代理运行可以在哪里添加代理呢?
1677578340145
上图是我本地开了全局代理后运行提示ssl错误
1677578409003
上图是本地关了全局代理后运行提示超时,

为什么要提示 正在思考中...

RT,服务号的这个提示是不是多余的。如果是微信的机制,我们是不是可以直接回复success或者空字符串,这样用户不会收到这样尴尬的消息

一个绕过微信15秒超时的办法

因为chatgpt随便15秒超时导致未认证用户几乎没法用了,稍微调整了下代码让其可以通过用户追问"继续"的方式绕过15秒超时限制,供参考。
`import werobot
import time
from config import channel_conf
from common import const
from common.log import logger
from channel.channel import Channel
from concurrent.futures import ThreadPoolExecutor

robot = werobot.WeRoBot(token=channel_conf(const.WECHAT_MP).get('token'))
thread_pool = ThreadPoolExecutor(max_workers=8)
cache = {}

@robot.text
def hello_world(msg):
logger.info('[WX_Public] receive public msg: {}, userId: {}'.format(msg.content, msg.source))
key = msg.content + '|' + msg.source
if cache.get(key):
# request time
cache.get(key)['req_times'] += 1
return WechatSubsribeAccount().handle(msg)

class WechatSubsribeAccount(Channel):
def startup(self):
logger.info('[WX_Public] Wechat Public account service start!')
robot.config['PORT'] = channel_conf(const.WECHAT_MP).get('port')
robot.config['HOST'] = '0.0.0.0'
robot.run()

def handle(self, msg, count=0):
    context = dict()
    context['from_user_id'] = msg.source
    key = msg.source
    res = cache.get(key)
    if msg.content == "继续":
        if not res or res.get("status") == "done":
            return "目前不在等待回复状态,请输入对话"
        if res.get("status") == "waiting":
            return "还在处理中,请稍后再试"
        elif res.get("status") == "success":
            cache[key] = {"status":"done"}
            return res.get("data")
        else:
            return "目前不在等待回复状态,请输入对话"
    elif not res or res.get('status') == "done":
        thread_pool.submit(self._do_send, msg.content, context)
        return "已开始处理,请稍等片刻后输入\"继续\"查看回复"
    else:
        if res.get('status') == "done":
            reply = res.get("data")
            thread_pool.submit(self._do_send, msg.content, context)
            return reply
        else:
            return "上一句对话正在处理中,请稍后输入\"继续\"查看回复"

def _do_send(self, query, context):
    key = context['from_user_id']
    cache[key] = {"status": "waiting"}
    reply_text = super().build_reply_content(query, context)
    logger.info('[WX_Public] reply content: {}'.format(reply_text))

    cache[key] = {"status": "success", "data": reply_text}`

订阅号问题

我看文档订阅号也可以微信认证获得客服接口。这样不会有15s的问题吗

公众号配置服务器地址,请求url超时问题

服务器地址 (URL) 配置: 如果在浏览器上通过配置的URL 能够访问到服务器上的Python程序 (默认监听8088端口),则说明配置有效。由于公众号只能配置 80/443端口,可以修改配置为直接监听 80 端口 (需要sudo权限),或者使用反向代理进行转发 (如nginx)。 根据官方文档说明,此处填写公网ip或域名均可。

公众号配置服务器地址这总返回请求url超时,启动不了,是怎么回事?大佬们

可否支持配置一个三方回调?

  • bot-on-anything

    • 部署后暴漏一个接口,用来接收问题和id,通过chatgpt拿到问题回复后,调用三方接口进行回调
  • 三方

    • 一个回调地址,供bot-on-anything携带chatgpt回复访问

为什么运行需要权限

RT 我用chatgpt-on-wechat 上运行的时候是可以不用root的,但是用这个代码跑的时候就一直要权限。是哪里加了什么包导致的吗?

Gmail 模式启动报错Invalid credentials或Connection timed out

我成功接入了微信,但是在Gmail启动时会报错Invalid credentials或Connection timed out。我注册和登陆 openai 都是用的是谷歌邮箱(并不是使用谷歌账号)。我配置代理后报错Invalid credentials,未配置时连接超时。这是什么原因呢?

RuntimeError

Traceback (most recent call last):
File "app.py", line 22, in
channel.startup()
File "/usr/src/bot-on-anything/channel/terminal/terminal_channel.py", line 21, in startup
for res in super().build_reply_content(prompt, context):
File "/usr/src/bot-on-anything/channel/channel.py", line 31, in build_reply_content
return Bridge().fetch_reply_content(query, context)
File "/usr/src/bot-on-anything/bridge/bridge.py", line 9, in fetch_reply_content
return model_factory.create_bot(config.conf().get("model").get("type")).reply(query, context)
File "/usr/src/bot-on-anything/model/model_factory.py", line 19, in create_bot
raise RuntimeError
RuntimeError

你好 报了这个错 没找着是啥原因

使用terminal 模式时,报错以下内容?

Please input your question
User:
nihao
Bot:
[ERROR][2023-02-21 17:44:39][log.py:50] - Internal server error {
"error": {
"message": "Internal server error",
"type": "auth_subrequest_error",
"param": null,
"code": "internal_error"
}
}

请再问我一次吧

[INFO][2023-02-21 15:44:50][open_ai_bot.py:20] - [OPEN_AI] query=吧
[ERROR][2023-02-21 15:44:55][open_ai_bot.py:64] - Internal server error {
"error": {
"message": "Internal server error",
"type": "auth_subrequest_error",
"param": null,
"code": "internal_error"
}
}
500 {'error': {'message': 'Internal server error', 'type': 'auth_subrequest_error', 'param': None, 'code': 'internal_error'}} {'Date': 'Tue, 21 Feb 2023 07:44:55 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '166', 'Connection': 'keep-alive', 'Vary': 'Origin', 'X-Request-Id': 'bbbcfa735c6c715e8fdd7677b0773558', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}
Traceback (most recent call last):
File "/home/lighthouse/chatgpt-on-wechat003/bot/openai/open_ai_bot.py", line 40, in reply_text
response = openai.Completion.create(
File "/home/lighthouse/miniconda3/envs/chatgpt-wechat-bot/lib/python3.9/site-packages/openai/api_resources/completion.py", line 25, in create
return super().create(*args, **kwargs)
File "/home/lighthouse/miniconda3/envs/chatgpt-wechat-bot/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "/home/lighthouse/miniconda3/envs/chatgpt-wechat-bot/lib/python3.9/site-packages/openai/api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
File "/home/lighthouse/miniconda3/envs/chatgpt-wechat-bot/lib/python3.9/site-packages/openai/api_requestor.py", line 619, in _interpret_response
self._interpret_response_line(
File "/home/lighthouse/miniconda3/envs/chatgpt-wechat-bot/lib/python3.9/site-packages/openai/api_requestor.py", line 679, in _interpret_response_line
raise self.handle_error_response(
openai.error.APIError: Internal server error {
"error": {
"message": "Internal server error",
"type": "auth_subrequest_error",
"param": null,
"code": "internal_error"
}
}
500 {'error': {'message': 'Internal server error', 'type': 'auth_subrequest_error', 'param': None, 'code': 'internal_error'}} {'Date': 'Tue, 21 Feb 2023 07:44:55 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '166', 'Connection': 'keep-alive', 'Vary': 'Origin', 'X-Request-Id': 'bbbcfa735c6c715e8fdd7677b0773558', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}
[INFO][2023-02-21 15:44:55][wechat_channel.py:103] - [WX] sendMsg=请再问我一次吧, receiver=@0d2b74afb9ab3fc0554dfb5c2e6a05b5

可以提供docker内支持吗

跑了一下微信公众号配置,发现监听的是127.0.0.1,在docker里无法生效,调整channel/wechat/wechat_mp_channel.py WechatSubsribeAccount startup方法添加 robot.config['HOST'] = '0.0.0.0'就可以正常工作了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.