Skip to main content

a reverse engineering of ERNIEBot

Project description

ERNIEBot

PyPi Support_Platform

在Python上使用文心一言。可拓展为各种聊天机器人。

欢迎提交Pull Request或者Issues来改进此项目 Make a pull request to improve this project

功能 / Fetures

  • 基于ACS-Token逆向(暂时未解决)
  • 使用Selenium和Browsermob-Proxy来与文心一言模拟交互

使用 / Get Start

如果要在你的项目上使用:

  1. 执行pip install wenxin -i https://pypi.org/simple/
  2. 【已发现的问题】需要在你的项目根目录上加上/src/wenxin文件夹,然后将本项目src/wenxin/browsermob-proxy-2.1.4文件夹和chromedriver.exe复制到/src/wenxin中
  3. 使用以下代码:
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参数,获取方法如下:

  1. 使用一个获得资格的账号登录https://yiyan.baidu.com/ ,然后打开F12,找到如图所示的请求,右键另存为HAR

image

  1. 找到cookies,如下图所示,然后复制整个列表放到代码上。然后使用文本替换工具将true替换为Truefalse替换为False

image

  1. 替换文本完成后,得到的列表就是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)

Uploaded Source

Built Distribution

Wenxin-1.1.4-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

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

Hashes for Wenxin-1.1.4.tar.gz
Algorithm Hash digest
SHA256 a5f5d20de8bc7884f22eefa2ec387906a3f1e69ba57aa4b2f0ad122cd2b6da75
MD5 f118173eed54d4f775ae5cde15cae3aa
BLAKE2b-256 1fecb0bf75be2191ff0c869fce84a2b26cd904c6bdf3b06747430b156f83f6d1

See more details on using hashes here.

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

Hashes for Wenxin-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8d7080adc19c760979a3aa3ebb314e3c05627f1862ae2750bd7ffca3565fc492
MD5 0bdd227ccb473ff967c0ee80c78e4789
BLAKE2b-256 4bc9c5db07cea70de8db6d8f1b16dd9f458e5344aa54ba7408d32031fa31459f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page