百度文心一言逆向工程
Project description
revERNIEBot
文心一言 API
- Selenium方法
- requests调用协议方法
目前仅支持使用Selenium的方案
安装
安装Chrome
Windows系统
自行前往 https://www.google.cn/chrome/index.html 下载安装
Ubuntu/Debian系统
安装依赖软件
sudo apt install udev fonts-liberation libu2f-udev libvulkan1 xdg-utils -y
下载Chrome安装包
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
安装Chrome
sudo dpkg -i google-chrome-stable_current_amd64.deb
检查Chrome版本
google-chrome -version
记住此版本号
CentOS/Rocky Linux系统
安装Chrome
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
下载browsermob-proxy
点击此处展开
前往 https://github.com/lightbody/browsermob-proxy/releases/tag/browsermob-proxy-2.1.4
下载 browsermob-proxy-2.1.4-bin.zip,解压
使用
- 安装本依赖库
pip3 install --upgrade revERNIEBot
-
安装 Chrome/Edge 或 Firefox 上的Cookies Editor插件
-
前往yiyan.baidu.com
-
打开此插件,点击
Export->Export as JSON,将复制的Cookies内容保存到文件cookies.json -
代码调用
from revERNIEBot.selenium import ChatBot # 目前仅支持Selenium的方案
chatbot = ChatBot(
cookieFile="cookies.json"
browsermobProxyPath="pathToBrowserMobProxyExecFile", # browsermob-proxy的可执行文件路径,详见下方说明
)
print(chatbot.ask("你好")) # 获取回复
print(chatbot.ask("你是谁?"))
chatbot.reset_session() # 开启新对话
chatbot.quit()
browsermobProxyPath:填写刚刚下载的browsermobproxy的压缩包解压出来的bin/中的可执行文件路径,例如Linux系统下填写bin中的browsermob-proxy的路径,Windows填写browsermob-proxy.bat路径(Windows系统下需要将路径使用\分隔)- 系统上的java版本不能高于java8
注意
- 有问题请在issue中发起讨论
- 此仓库仅供学习
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
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
File details
Details for the file reverniebot-0.0.7.tar.gz.
File metadata
- Download URL: reverniebot-0.0.7.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e91cb294c052b1a141adbf008d692b120cac73151ba714fd8e5281b5653f653
|
|
| MD5 |
cfe54aa37f020147b2711ac5e3a9ef95
|
|
| BLAKE2b-256 |
16ef4d431c1721442ee2f43a5277dde36666abf1bd7150031595d115db66611d
|
File details
Details for the file reverniebot-0.0.7-py3-none-any.whl.
File metadata
- Download URL: reverniebot-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f023d3fea1e04750646df13931b2460e3bdd335a78253e8cbfb258567a6f1615
|
|
| MD5 |
0e40af17d9bd57feb5c52d2458634d6d
|
|
| BLAKE2b-256 |
c208891c3eed32f7f58872c7a51e394a41934963a4d3472885ee35f0b3490d00
|