阿里通义千问逆向工程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.1.tar.gz
(18.8 kB
view hashes)
Built Distribution
Close
Hashes for revtongyi-0.0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed02bdae35241ea53cca76c91592e23c0d5190f32b1818c646159439ac904014 |
|
MD5 | e338c0c3b4a6c1726639438f83d5bbb5 |
|
BLAKE2b-256 | ebc572496bbdc59de99a845f37e7442f52ac3c3bbc0601fc1e10da9abb3bce52 |