Skip to main content

阿里通义千问逆向工程API

Project description

revTongYi

PyPi Downloads

阿里通义千问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模式

  1. 安装 Chrome/EdgeFirefox 上的Cookies Editor插件
  2. 前往https://tongyi.aliyun.com/chat 并登录
  3. 打开此插件,点击Export->Export as JSON,将复制的Cookies内容保存到文件cookies.json
python -m revTongYi.__init__

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

revtongyi-0.0.2.2.tar.gz (18.8 kB view hashes)

Uploaded Source

Built Distribution

revtongyi-0.0.2.2-py3-none-any.whl (16.9 kB view hashes)

Uploaded Python 3

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