阿里通义千问逆向工程API
Project description
revTongYi
阿里通义千问Python逆向API
pip install revTongYi --upgrade
- 需要通义千问测试资格
# 非流式模式
import revTongYi.qianwen as qwen
question = "人工智能将对人类社会发展产生什么影响?"
chatbot = qwen.Chatbot(
cookies=<cookies_dict> # 以dict形式提供cookies
)
# chatbot = qwen.Chatbot(
# cookies_str=<cookies_str> # 您也可以使用字符串形式提供cookies,cookies字符串可以从浏览器的请求头中获取
# )
print(chatbot.ask(prompt=question))
# 流式模式
import revTongYi.qianwen as qwen
question = "人工智能将对人类社会发展产生什么影响?"
chatbot = qwen.Chatbot(
cookies=<cookies_dict> # 以dict形式提供cookies
)
for resp in chatbot.ask(prompt=question, stream=True):
print(resp)
列出会话列表
sessions = chatbot.list_session()
删除指定会话
chatbot.delete_session(sessionId=<session_id>)
修改会话标题
chatbot.update_session(sessionId=<session_id>, summary=<new_title>)
CLI模式
- 安装 Chrome/Edge 或 Firefox 上的Cookies Editor插件
- 前往https://tongyi.aliyun.com/chat 并登录
- 打开此插件,点击
Export
->Export as JSON
,将复制的Cookies内容保存到文件cookies.json
python -m revTongYi.__init__
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
revtongyi-0.0.2.2.tar.gz
(18.8 kB
view hashes)
Built Distribution
Close
Hashes for revtongyi-0.0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5b76cdba97ed3dc383e33c075d8460902c43cf40597bf3251cb86c2d6583588 |
|
MD5 | b3132806d6526a34b8255d4b70efe00a |
|
BLAKE2b-256 | c2d5038468ea5254a78b47dac2c3b39dd713961383fef9049ac0a7c153977201 |