a reverse engineering of ERNIEBot
Project description
ERNIEBot
在Python上使用文心一言。可拓展为各种聊天机器人。
欢迎提交Pull Request或者Issues来改进此项目 Make a pull request to improve this project
功能 / Fetures
- 基于ACS-Token逆向(暂时未解决)
- 使用Selenium和Browsermob-Proxy来与文心一言模拟交互
使用 / Get Start
如果要在你的项目上使用:
- 执行
pip install wenxin -i https://pypi.org/simple/ - 【已发现的问题】需要在你的项目根目录上加上/src/wenxin文件夹,然后将本项目src/wenxin/browsermob-proxy-2.1.4文件夹和chromedriver.exe复制到/src/wenxin中
- 使用以下代码:
from wenxin.wenxin import WenXinBot
from wenxin.wenxin import WenxinRevError
# wenxin_cookies_dict_list 的内容详见下文
wx = WenXinBot(wenxin_cookies_dict_list)
# 初始化selenium,debug=True时,会输出调试信息,方便调试。headless=False时,会打开浏览器。
wx.initSelenium(debug=False, headless=True)
# 超时设置,单位秒,防止长时间等待,当超时后,会将已经生成的文本返回
res = wx.chatViaSelenium('hello', timeout=20)
print(res)
wx = WenXinBot()需要传入一个cookie参数,获取方法如下:
- 使用一个获得资格的账号登录https://yiyan.baidu.com/ ,然后打开F12,找到如图所示的请求,右键另存为HAR
- 找到cookies,如下图所示,然后复制整个列表放到代码上。然后使用文本替换工具将
true替换为True,false替换为False
- 替换文本完成后,得到的列表就是wx = WenXinBot()要传入的参数了。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Wenxin-1.1.4.tar.gz
(18.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
Wenxin-1.1.4-py3-none-any.whl
(18.0 kB
view details)
File details
Details for the file Wenxin-1.1.4.tar.gz.
File metadata
- Download URL: Wenxin-1.1.4.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f5d20de8bc7884f22eefa2ec387906a3f1e69ba57aa4b2f0ad122cd2b6da75
|
|
| MD5 |
f118173eed54d4f775ae5cde15cae3aa
|
|
| BLAKE2b-256 |
1fecb0bf75be2191ff0c869fce84a2b26cd904c6bdf3b06747430b156f83f6d1
|
File details
Details for the file Wenxin-1.1.4-py3-none-any.whl.
File metadata
- Download URL: Wenxin-1.1.4-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d7080adc19c760979a3aa3ebb314e3c05627f1862ae2750bd7ffca3565fc492
|
|
| MD5 |
0bdd227ccb473ff967c0ee80c78e4789
|
|
| BLAKE2b-256 |
4bc9c5db07cea70de8db6d8f1b16dd9f458e5344aa54ba7408d32031fa31459f
|