
[英语] | [中文]
任何东西上的机器人都是功能强大的AI聊天机器人构建器,可让您快速构建聊天机器人并在任何地方运行它们。
开发人员可以通过选择具有轻量级配置的各种AI大型模型和应用程序渠道之间的连接来构建和运行智能对话机器人。它支持在单个项目中的多个路径之间轻松切换。该体系结构具有强大的可扩展性。每个应用程序都可以重复使用现有的模型功能,并且每个新模型都可以在所有应用程序渠道上运行。
型号:
应用程序:
必须安装支持Linux,MacOS和Windows系统,并且必须安装Python。建议在3.7.1和3.10之间使用Python版本。
克隆项目代码并安装依赖项:
git clone https://github.com/zhayujie/bot-on-anything
cd bot-on-anything/
pip3 install -r requirements.txt核心配置文件是config.json ,并且在项目中提供了模板文件config-template.json ,可以复制该文件以生成最终有效config.json文件:
cp config-template.json config.json每个模型和频道都有自己的配置块,共同形成一个完整的配置文件。总体结构如下:
{
" model " : {
" type " : " openai " , # Selected AI model
" openai " : {
# openAI configuration
}
},
" channel " : {
" type " : " slack " , # Channel to be integrated
" slack " : {
# slack configuration
},
" telegram " : {
# telegram configuration
}
}
}配置文件分为model ,并在最外面的级别进行channel部分。模型部分用于模型配置,其中type指定使用哪些模型;频道部分包含应用程序频道的配置, type字段指定要集成的应用程序。
使用时,您只需要更改模型和通道配置块下的type字段即可在任何模型和应用程序之间切换,从而连接不同的路径。下面,将依次介绍每个模型和应用程序配置和运行过程。
在项目根目录中运行以下命令,默认频道是终端:
python3 app.py默认模型是gpt-3.5-turbo 。有关详细信息,请参阅官方文件。它还支持gpt-4.0 ,只需修改模型类型参数即可。
pip3 install --upgrade openai注意:OpenAI版本需要高于
0.27.0。如果安装失败,则可以首先使用pip3 install --upgrade pip。
{
" model " : {
" type " : " chatgpt " ,
" openai " : {
" api_key " : " YOUR API KEY " ,
" model " : " gpt-3.5-turbo " , # Model name
" proxy " : " http://127.0.0.1:7890 " , # Proxy address
" character_desc " : " You are ChatGPT, a large language model trained by OpenAI, aimed at answering and solving any questions people have, and can communicate in multiple languages. When asked who you are, you should also tell the questioner that entering #clear_memory can start a new topic exploration. Entering draw xx can create a picture for you. " ,
" conversation_max_tokens " : 1000, # Maximum number of characters in the reply, total for input and output
" temperature " :0.75, # Entropy, between [0,1], the larger the value, the more random the selected candidate words, the more uncertain the reply, it is recommended to use either this or the top_p parameter, the greater the creativity task, the better, the smaller the precision task
" top_p " :0.7, # Candidate word list. 0.7 means only considering the top 70% of candidate words, it is recommended to use either this or the temperature parameter
" frequency_penalty " :0.0, # Between [-2,2], the larger this value, the more it reduces the repetition of words in the model's output, leaning towards producing different content
" presence_penalty " :1.0, # Between [-2,2], the larger this value, the less restricted by the input, encouraging the model to generate new words not present in the input, leaning towards producing different content
}
}api_key :填写注册帐户时创建的OpenAI API KEY 。model :当前支持gpt-3.5-turbo , gpt-4 , gpt-4-32k (GPT-4 API尚未打开)。proxy :代理客户端的地址,有关详细信息,请参阅#56。character_desc :此配置保存了您对chatgpt说的文本,它将记住此文本作为其设置;您可以自定义任何个性。max_history_num [可选]:对话的最大内存长度,超过此长度将清除先前的内存。{
" model " : {
" type " : " linkai " ,
" linkai " : {
" api_key " : " " ,
" api_base " : " https://api.link-ai.tech " ,
" app_code " : " " ,
" model " : " " ,
" conversation_max_tokens " : 1000,
" temperature " :0.75,
" top_p " :0.7,
" frequency_penalty " :0.0,
" presence_penalty " :1.0,
" character_desc " : " You are an intelligent assistant. "
},
}api_key :调用Linkai服务的键,可以在控制台中创建。app_code :Linkai应用程序或工作流的代码,可选,请参阅应用程序创建。model :支持来自国内和国际来源的通用模型,请参阅模型列表。它可以留为空白,并且可以在Linkai平台中修改应用程序的默认模型。默认情况下,在配置模板中启动的应用程序是终端,不需要其他配置。您可以直接在项目目录中执行python3 app.py来启动程序。用户通过命令行输入与对话模型进行交互,并且它支持流响应效果。

贡献者:治疗疗法
依赖性
pip3 install PyJWT flask flask_socketio配置
" channel " : {
" type " : " http " ,
" http " : {
" http_auth_secret_key " : " 6d25a684-9558-11e9-aa94-efccd7a0659b " , // JWT authentication secret key
" http_auth_password " : " 6.67428e-11 " , // Authentication password, just for personal use, a preliminary defense against others scanning ports and DDOS wasting tokens
" port " : " 80 " // Port
}
}在本地运行:运行python3 app.py后,访问http://127.0.0.1:80 。
在服务器上运行:部署后,访问http://public domain or IP:port 。
要求:服务器和订阅帐户。
安装WeroBot依赖性:
pip3 install werobot " channel " : {
" type " : " wechat_mp " ,
" wechat_mp " : {
" token " : " YOUR TOKEN " , # Token value
" port " : " 8088 " # Port the program listens on
}
}在项目目录中运行python3 app.py如果终端显示以下内容,则表示成功的操作:
[INFO][2023-02-16 01:39:53][app.py:12] - [INIT] load config: ...
[INFO][2023-02-16 01:39:53][wechat_mp_channel.py:25] - [WX_Public] Wechat Public account service start!
Bottle v0.12.23 server starting up (using AutoServer())...
Listening on http://127.0.0.1:8088/
Hit Ctrl-C to quit.
转到微信官方平台中的个人订阅帐户,并启用服务器配置:

服务器地址(URL)配置:如果您可以通过浏览器中的已配置URL访问服务器上的Python程序(默认收听端口8088),则表明配置是有效的。由于订阅帐户只能配置端口80/443,因此您可以修改配置以直接在端口80上收听(需要sudo权限)或使用反向代理转发(例如nginx)。根据官方文档,您可以在此处填写公共IP或域名。
令牌配置:必须与config.json配置中的令牌一致。
有关详细的操作流程,请参阅官方文档。
用户遵循订阅帐户后,他们可以发送消息。
注意:用户发送消息后,微信后端将推到配置的URL地址,但是如果在5秒内没有答复,则该连接将被断开,并且会重试3次。但是,对OpenAI接口的请求通常需要超过5秒。在这个项目中,异步和缓存方法已将5秒的超时限制优化为15秒,但超过这段时间仍然不允许正常答复。同时,每次连接在5秒后断开连接时,Web框架将报告一个错误,稍后将进行优化。
要求:服务器和经过认证的服务帐户。
在企业服务帐户中,通过第一个异步访问OpenAI界面,然后通过客户服务界面主动将用户推向用户,从而解决了个人订阅帐户的15秒超时问题。服务帐户的开发人员模式配置与订阅帐户的配置相似。有关详细信息,请参阅官方文件。
企业服务帐户的config.json配置仅需要将类型更改为wechat_mp_service ,但是配置块仍然重新使用wechat_mp ,此外,您需要添加两个配置项目: app_id and app_secret 。
" channel " : {
" type " : " wechat_mp_service " ,
" wechat_mp " : {
" token " : " YOUR TOKEN " , # Token value
" port " : " 8088 " , # Port the program listens on
" app_id " : " YOUR APP ID " , # App ID
" app_secret " : " YOUR APP SECRET " # App secret
}
}注意:必须在“ IP白名单”中配置服务器IP地址;否则,用户将不会主动收到被推动的消息。
要求:PC或服务器(国内网络)和QQ帐户。
运行QQ机器人需要额外运行一个go-cqhttp程序,该程序负责接收和发送QQ消息,而我们的bot-on-anything程序都负责访问OpenAI来生成对话内容。
从GO-CQHTTP版本下载相应的计算机程序,解压缩IT,然后将go-cqhttp二进制文件放置在我们的bot-on-anything/channel/qq目录中。 config.yml配置文件在这里已经准备好;您只需要填写QQ帐户配置(Account-uin)即可。
使用AIOCQHTTP与GO-CQHTTP进行交互,执行以下命令以安装依赖关系:
pip3 install aiocqhttp只需将config.json配置文件的通道块中的type更改为qq :
" channel " : {
" type " : " qq "
}首先,转到bot-on-anything的根目录,并在1号终端运行:
python3 app.py # This will listen on port 8080在第二步(开放终端2)中,导航到cqhttp所在的目录并运行:
cd channel/qq
./go-cqhttp笔记:
device.json中的protocol值。JSON文件与GO-CQHTTP相同的目录中的JOSON文件从5到2,请参阅此问题。撰稿人:Brucelt1993
6.1获得令牌
可以在Google上轻松找到申请电报机器人;重要的是要获取机器人的令牌ID。
6.2依赖项安装
pip install pyTelegramBotAPI6.3配置
" channel " : {
" type " : " telegram " ,
" telegram " :{
" bot_token " : " YOUR BOT TOKEN ID "
}
}要求:服务器和Gmail帐户。
贡献者:西蒙
请按照官方文档为您的Google帐户创建应用程序密码,以下配置,然后加油!!!
" channel " : {
" type " : " gmail " ,
" gmail " : {
" subject_keyword " : [ " bot " , " @bot " ],
" host_email " : " [email protected] " ,
" host_password " : " GMAIL ACCESS KEY "
}
}❉不再需要服务器或公共IP
贡献者: Amaoo
依赖性
pip3 install slack_bolt配置
" channel " : {
" type " : " slack " ,
" slack " : {
" slack_bot_token " : " xoxb-xxxx " ,
" slack_app_token " : " xapp-xxxx "
}
}设置机器人令牌范围 - OAuth&许可
将bot用户oauth令牌写入配置文件slack_bot_token 。
app_mentions:read
chat:write
启用插座模式 - 插座模式
如果您尚未创建应用程序级令牌,将提示您创建一个。将创建的令牌写入配置文件slack_app_token 。
事件订阅(事件订阅) - 订阅机器人事件
app_mention
参考文档
https://slack.dev/bolt-python/tutorial/getting-started
要求:
依赖性
pip3 install requests flask配置
" channel " : {
" type " : " dingtalk " ,
" dingtalk " : {
" image_create_prefix " : [ " draw " , " draw " , " Draw " ],
" port " : " 8081 " , # External port
" dingtalk_token " : " xx " , # Access token of the webhook address
" dingtalk_post_token " : " xx " , # Verification token carried in the header when DingTalk posts back messages
" dingtalk_secret " : " xx " # Security encryption signature string in the group robot
}
}参考文档:
生成机器人
地址:https://open-dev.dingtalk.com/fe/app#/corp/robot添加机器人,在开发管理中设置服务器的出站IP和消息接收地址(配置中的外部地址,例如https://xx.xx.xx.com:8081)。
依赖性
pip3 install requests flask配置
" channel " : {
" type " : " feishu " ,
" feishu " : {
" image_create_prefix " : [
" draw " ,
" draw " ,
" Draw "
],
" port " : " 8082 " , # External port
" app_id " : " xxx " , # Application app_id
" app_secret " : " xxx " , # Application Secret
" verification_token " : " xxx " # Event subscription Verification Token
}
}生成机器人
地址:https://open.feishu.cn/app/
要求:服务器和经认证的企业微信。
Enterprise Wechat的config.json配置只需要将类型更改为wechat_com ,而默认消息接收服务器URL:http:// ip:88888/wechat。
" channel " : {
" type " : " wechat_com " ,
" wechat_com " : {
" wechat_token " : " YOUR TOKEN " , # Token value
" port " : " 8888 " , # Port the program listens on
" app_id " : " YOUR APP ID " , # App ID
" app_secret " : " YOUR APP SECRET " , # App secret
" wechat_corp_id " : " YOUR CORP ID " ,
" wechat_encoding_aes_key " : " YOUR AES KEY "
}
}注意:必须在“企业信任的IP”列表中配置服务器IP地址;否则,用户将不会主动收到被推动的消息。
参考文档:
clear_memory_commands :对话内部命令积极清除先前的内存,字符串数组可以自定义命令别名。