Git Product home page Git Product logo

chatgpt-webot's Introduction

ChatGPT-weBot

[TOC]

GitHub tag (latest by date)

Using ChatGPT-weBot based on ChatGPT(API key call), Stable Diffusion AI drawing and official WeChat hook interface. 中文文档 | English

Author

Snapdragon Lee (github.com)

cover created from DALL·E3 (openai.com)

Support & Features

  • Support conversation
  • Support context-aware question answering
  • Support multithreaded Stable Diffusion AI drawing (English Only, Support (Negative) Prompt)
  • Never get banned by using official WeChat execution
  • Support API calls for gpt-3.5-turbo and newer models
  • Support WebChatGPT function
  • Support bot's character setting
  • Set the keywords to wake up the WeChat robot in private
  • Set the keywords to wake up the WeChat robot in the group
  • Support replying at-message when mentioning your bot in the group
  • Get help doc inline
  • Regenerate conversation
  • Rollback conversation
  • Conclusion (save token consumption)
  • Reset the whole conversation
  • Support multithreaded conversation in one account
  • No need to manually reboot service after error exists
  • Other

Default configs (Follow steps before you start server)

---> Configurable options detailed guide

Step to Start

  1. Environment: Windows 7+, python 3.7+

  2. Install all packages listed in requirements.txt , use the command like:

    pip install -r ./requirements.txt

    Note that v1.2 requires more packages to be installed and upgraded, so please execute this command once after upgrading.

  3. Download package from Github Releases. (You can download it step by step when they are mentioned)

  4. Install WeChat-3.9.5.81.exe on your computer, if your version is higher than 3.9.5.81, you can downgrade instantly, or install seperately in other directory. Afterwards, please start it as an administrator and log in. **If you want to dual-open WeChat, you need to install two different versions and modify ./dual-start.bat according to the comments **, the subsequent steps are slightly different, please continue to read [here](. /doc/Dual_Start.md).

  5. Monitoring WeChat message by running a server. It has been modified to 1 solution after version V1.20:

    >  cd .\wxinject\bin\
    >  .\injector.exe -n WeChat.exe -i .\wxinject.dll
  6. The last step is fill json files listed in .config/ .

    • In api_config.json, you need to fill in your own parameter settings for API calls. If you don’t know the specific parameters, you only need to fill in the "api_key" and optional "proxy" items.

    • In server_config.json, you can customize the listening address and port. If you don’t know it exactly, no modification needed by default.

    • In config.json , you need to configure your custom options based on your preferences.

    • In sys_character.json, you can customize the character the bot needs to play, and use the command to activate when chatting.

  7. Run main.py by using command:

    python main.py
    

    Everything is ready, feel free to go online with your ChatGPT-weBot !

    No limitation, but since switching to OpenAI API, there are usage counts and payment requirements.

Q&A

  1. How to get all response? You can say "continue" in your language.

  2. Have problems? Feel free to create an issue.

  3. How to trace problems in multithreaded program? Print or using debug with information of thread-stack.

  4. Have any preview images related to functionality? Yes, go to -> Preview

  5. Wanna buy me coffee? Thank you, qrcode is as follows.

    image-20230321150123666

Who has starred

Stargazers repo roster for @SnapdragonLee/ChatGPT-weBot

Stargazers over time

Stargazers over time

Log

  • 2023.10.23 Version v1.20.2 is released, fix some memory leak and change XML parser.
  • 2023.10.18 Version v1.2 is released, with new SDK and new WeChat version.
  • 2023.10.17 Complete the Python ws_client, update the source code to support the new SDK, and prepare for main architecture upgrades
  • 2023.10.15 A large number of APIs are added and type-testing is conducted
  • 2023.10.10 Build and improve the SDKs and support the ws client
  • 2023.3.24 Exception handler updates and other pull requests from rogue-shadowdancer and wbbeyourself
  • 2023.3.23 Fix bugs for Stable Diffusion and others, released v1.01 version
  • 2023.3.21 Add plenty of new features, fixed bugs, released v1.00 version
  • 2023.3.4 Add Stable Diffusion into function (English Only)
  • 2023.3.3 Add multithread and rewrite the whole program structure
  • 2023.2.27 Add zip version of WeChat and dual-start.bat, fix the bug that prevents other operations when the response keyword is empty
  • 2023.2.25 Add the option in config.json to quote the original question before answering
  • 2023.2.25 Complete all API function on features and Debugs for errors
  • 2023.2.23 Accomplish some API listed on features
  • 2023.2.23 Fix streaming issue when connecting to reverse server
  • 2023.2.21 Report issue on ChatGPT API
  • 2023.2.20 v0.90-dev released, for basic ChatGPT API usage on WeChat
  • 2023.2.17 Start to develop the whole process
Reference

chatgpt-webot's People

Contributors

jk256 avatar rogue-shadowdancer avatar snapdragonlee avatar wbbeyourself 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

chatgpt-webot's Issues

报错,没有这个模块

Traceback (most recent call last):
File "main.py", line 1, in
from client.wxclient import ws
ImportError: No module named client.wxclient

集中更新2023.3.21

下一个版本是正式版,会在明天开始集中测试后发布,这两周太忙了,一直没有大把时间搞这个。
具体的改进目标如下:

  1. 转移到 gpt3.5-turbo 的 API 调用
  2. 尽可能的异常处理
  3. 解决异常退出后需要手动重启服务的问题
  4. webchatgpt功能嵌入
  5. 人格设定 character_desc(以及更多的设定)
  6. 图像生成的正负prompt
  7. 全部使用API_token登录
  8. readme完善
  9. 有哥们 姐姐想buy me coffee的话,可以但是不要多,公益发电,为爱奉献

实验性(绕过 requests 频率限制,多账号回复支持,使用session_token登录,取消账号密码登录)

按说明配置好以后报错显示连接太多

显示成功登录chatgpt,网页也试过登录没问题
一但输入消息就报如下错误
requests.exceptions.SSLError: HTTPSConnectionPool(host='apps.openai.com', port=443): Max retries exceeded with url: /api/conversation (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:997)')))

代理问题Issue专区

大家因为代理问题可以把自己的使用环境,代理模式,操作流程,函数调用栈在这里详细列出,我不能保证给大家一一解决问题但是大家可以互相借鉴经验参考

#6 中代理问题请转移到这里

可否增加一点小提示

有时候回复等待时间较长,建议可以在一定秒数后输出“请耐心等待”之类的提示,以便知道机器人还没死掉。。。

发生了bug,可以在这里留言

发生了bug,可以在这里留言,或者自己单开issue也是可以的,我最后都会在这个issue里面汇总,并在一段时间后开新的bug帖。另外如果你已经修复好了,也欢迎提交PR

这个框架是单线程的吗,也就是只能一个一个问题问吗?

我在使用机器人的时候,如果一个问题比较难,机器人会花两分钟来回答这个问题,那么这个主程序就会卡住两分钟,期间不会对任何事情产生响应,也没有 heart beat。并且当两个人同时问问题的时候,它会忽略掉第二个问题。

使用一段时间后,微信号的桌面登录功能貌似被封了

我大约正常使用了1天,然后手机和桌面微信突然被迫下线,提示“账号状态异常,本次登录已失效,请尝试重新登录,并根据弹窗提示操作”。之后手机可以重新登录,并且没有安全提示,但是桌面微信扫码后一直停留在登陆界面,手机上显示“暂时无法登录,请尝试重新登录”。尝试用别人账号扫描同样的二维码发现他的号可以正常登录,看来好像是我微信号的桌面登录功能被封了。有没有同样遇到我这样问题的?有没有解决方法?被封的原因会是因为运行了”DLLinjector“被官方检测到了吗?

自动重置

当api过于拥挤:We're currently processing too many requests. Please try again later. 后机器人不会自动重置,需要手动重启

纯新手小白的详细解释指导

(省流量一句话:config.json里面的两个chatkey修改后,保存保存保存--->cmd.exe要重新运行main.py,然后才能生效)

环境:旧电脑win7,python官网下载python 3.8.10, installer,32位置,默认方式安装

软件及安装包:releases中下载3.6.0.18版的微信安装包,文档最底部下载dll啥啥啥的(比我还菜鸡那也就不用琢磨这个部署方式了。

严格按照作者的123456顺序进行,就可以正常使用了。

容易出问题的地方(额,菜鸡本鸡遇到的情况):

1,pip指令不生效,搜一下,有两行代码,会重装一下,然后就可以用pip开始第一步
(作者补充一句,是python安装目录下的scripts目录没有加入系统环境变量导致的,如果你安装的是anaconda/minicona,那不会有这个问题)

2,默认配置中的keyword是-c,我在聊天中用的是c,名字叫错了,所以没有应答,同样的issue我已经进行了标记 #7

3,修改-c为其他内容后,重新运行 python main.py,再在微信中聊天就没问题了

4,keyword可以修改为中文,亲测可用。

Originally posted by @xy185 in #6 (comment)

JSONDecodeError("Expecting value", s, err.value) from None 然后闪退

在前一个bug贴看到有大佬说过这个问题,没想到我也遇到了。之前的帖子信息太多,单独开了一个
部署一直能使用,中间调整过几次config,就关闭重启了几次main.py,突然就会提示以下信息后自动退出了,多次重试重启无效,重装WX和python也无法恢复。是最新的版本
C:\Users\W10\Desktop\ChatGPT-weBot-master>python main.py Traceback (most recent call last): File "C:\Users\W10\Desktop\ChatGPT-weBot-master\main.py", line 1, in <module> from client.wxclient import ws File "C:\Users\W10\Desktop\ChatGPT-weBot-master\client\wxclient.py", line 11, in <module> config = json.load(f) ^^^^^^^^^^^^ File "C:\Users\W10\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 293, in load return loads(fp.read(), ^^^^^^^^^^^^^^^^ File "C:\Users\W10\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\W10\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\W10\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 4 column 16 (char 53)

报错使用chatgpt 网页的

1)) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests->-r ./requirements.txt (line 1)) (2022.12.7)
Installing collected packages: regex, tiktoken
Successfully installed regex-2023.3.23 tiktoken-0.3.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip3 install --upgrade pip
root@debian:~/ChatGPT-weBot# python3 main.py
{'content': 'hello guys', 'id': '20230324023319', 'receiver': 'CLIENT', 'sender': 'SERVER', 'srvid': 1, 'status': 'SUCCSESSED', 'time': '2023-03-24 02:33:19', 'type': 5}
{'content': '{"wx_code":"Joe1280520","wx_head_image":"http://wx.qlogo.cn/mmhead/ver_1/dGSfSuyic3PWEGAuJLc454ibUjT6kd1Ga9GHXstwE2YKfJTECrWWpNWv9g18vUP0YjAAAqRI0JkAdqgqpbPic1FXQVK86icr9jStU2lJ8AB8cZ0/132","wx_id":"wxid_t8u89ousa2l912","wx_name":"ChatGPT 2"}', 'id': '20230323143320', 'receiver': 'CLIENT', 'sender': 'SERVER', 'srvid': 1, 'status': 'SUCCSESSED', 'time': '2023-03-24 02:33:19', 'type': 6500}
{'content': '-c hello', 'id': '20230324023333', 'id1': '', 'id2': '', 'id3': '', 'srvid': 1, 'time': '2023-03-24 02:33:33', 'type': 1, 'wxid': 'peng1631988'}
ask:hello
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
self.run()
File "/root/ChatGPT-weBot/multithread/threads.py", line 23, in run
item.play()
File "/root/ChatGPT-weBot/basic/task.py", line 69, in play
self.reply += self.bot.ask(prompt=self.prompt, access_internet=self.access,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/ChatGPT-weBot/apibase/ChatGPTAPI.py", line 202, in ask
response_text = content["choices"][0]["message"]
~~~~~~~^^^^^^^^^^^
KeyError: 'choices'

web端的接口是不是官方准备关掉了

换了好几个梯子,都是说“We're currently processing too many requests. Please try again later. ”
不过用网页端人工输入就没事。
不知道为什么。。。

请求增加群消息总结要点功能

详细描述如下:
记录群成员发送过的信息,发送关键字命令之后,将本群成员发送过的消息喂给chatgpt总结聊天要点,chatgpt总结完聊天要点之后回传给客户端,然后清空本次记录的聊天信息,下一次再发送关键字命令时,总结的是新记录的聊天要点

示例如下:
image

请求支持OpenAI官方gpt3.5-turbo的API调用

现有的方式感觉都不太稳妥,请求直接调用官方的API,让用户可以自己选择是用session token还是API。
这样也能更好的支持未来的ChatGPT 4模型的调用。

能否在重启程序(关闭指令窗再新建一个,运行python)以后,还能保留/获取到之前的对话记录?

如题。因为我发现,有时候被限流或者别的错误后,机器人不会自行恢复,必须得重新启动程序才能让它继续运转。但是重新启动程序以后,会丢失所有的对话id。有没有办法将每个微信号(私信的和群聊的)的对话id,作为json文件存在服务器本地?并在每次有人提问时都尝试从这些json文件里,找到他对应的文件,并获取他的对话id?

使用时请编辑.config文件夹下的配置文件

注意,使用的时候请配置.config文件夹下两个配置文件,分别对应:
config.json,机器人触发指令的各种关键字,将机器人对话做成类似于命令行调用的工具
rev_config.json,对应命令行调用chatgpt API的操作,请仔细根据文档填写

关于响应关键词的问题

响应关键词有什么规则吗?

-c

前面一定要加 “-”么,能不能换成其他符号
或者直接用一个词语代替,比如 “机器人”

也就是:机器人 你好啊

还有一个问题,用电脑版微信输入“-c”识别不了,用手机又可以

v1.01 代码 bug 专用

由于新加入了个别包,请更新代码之后,运行一次 pip install -r requirements.txt

功能不起作用

// 查看可用命令帮助
"helpKey": "-h",
// 设置重置上下文关键词
"resetChatKey": "-rs",
// 设置重新生成答案关键词
"regenerateKey": "-rg",
// 设置回滚到以前的n个问题关键词
"rollbackKey": "-rb"
}
这些好像不起作用

Originally posted by @damingsi in #5 (comment)

用这个方法我的微信账号被封了

我用自己的微信小号按照文档配置后使用,自己家人2个人用不到2小时就微信号被封了,期间没有说敏感词汇。使用频率也很低。

不确定是什么原因“accessToken”

代理检查过了
rev_config里只填了session_token

error from callback <function on_open at 0x000001458B2FB380>: 'accessToken'
  File "C:\Python311\Lib\site-packages\websocket\_app.py", line 393, in _callback
    callback(self, *args)
  File "Z:\WeChatGPT\ChatGPT-weBot-0.98-dev\client\wxclient.py", line 364, in on_open
    chatbot = Chatbot(
              ^^^^^^^^
  File "Z:\WeChatGPT\ChatGPT-weBot-0.98-dev\revChat\revChatGPT.py", line 67, in __init__
    self.__check_credentials()
  File "Z:\WeChatGPT\ChatGPT-weBot-0.98-dev\revChat\revChatGPT.py", line 80, in __check_credentials
    self.login()
  File "Z:\WeChatGPT\ChatGPT-weBot-0.98-dev\revChat\revChatGPT.py", line 110, in login
    auth.get_access_token()
  File "C:\Python311\Lib\site-packages\OpenAIAuth.py", line 318, in get_access_token
    self.access_token = response.json()["accessToken"]
                        ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^

Originally posted by @Evander0 in #6 (comment)

v0.99-fix 版代码 bug 专用

v0.99-dev增加异步回复,多线程画图,以及修复了n多个bug,具体设置请参见 readme.md

由于v0.99-dev版本嵌入了线程与消息队列,难免会发生奇奇怪怪的bug。
命令行窗口是多线程打印信息,不专门找很难定位问题。所以当发生bug时,如果你可以trace数据流,那请你把这些珍贵的信息放在评论区;如果你不可以,那就把你遇到的现象放在这里也可以。

之前的bug issue也会在这里继续

逆向工程API已经G了,按道理只能等待

从CHATGPT返回错误代码有1020,我用chatgpt问了一下怎么回事:
chatgpt的Error code: 1020
如果您在使用 OpenAI 的 ChatGPT 模型时遇到 Error code 1020,那么可能是因为您的请 > 求不符合 API 的规范,或者出现了其他问题导致 API 调用失败。
建议您检查您的 API 请求,确保其符合 API 的规范。您还可以联系 OpenAI 的技术支持团> 队,以获得帮助。他们可以帮助您诊断和解决问题,以确保您的 API 调用正常工作。

我会观察作者 acheong08 的修改,修改好了我会尽快更改库里面与chatgpt连接的部分,现在先耐心等待一下吧

如果有非常紧急的任务,只能使用 chatgpt 网页版。

Originally posted by @LeonLee888 in #6 (comment)

ChatGPT response内容错误

刚才发现不能用了,Console里日志有输出如下内容

<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

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.