EdgeGPT - 微软必应聊天的逆向工程API

Created at: 2023-02-10 00:07:42
Language: Python
License: Unlicense
边缘GPT

边缘 GPT

新版必应的聊天功能逆向工程

PyPI 版本 蟒蛇版本


目录

设置

安装包

python3 -m pip install EdgeGPT --upgrade

要求

检查访问权限(必需)

  • 安装最新版本的微软边缘
  • 开放式 http://bing.com/chat
  • 如果你看到聊天功能,则很好

获取身份验证(必需)

  • 安装 ChromeFirefox 的 cookie 编辑器扩展
  • 转到
    bing.com
  • 打开扩展程序
  • 单击右下角的“导出”(这会将你的 cookie 保存到剪贴板)
  • 将你的饼干粘贴到文件中
    cookies.json

用法

快速入门

 $ python3 -m EdgeGPT -h

        EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit
        Enter twice to send message or set --enter-once to send one line message

usage: EdgeGPT.py [-h] [--enter-once] [--no-stream] [--style {creative,balanced,precise}] --cookie-file COOKIE_FILE

options:
  -h, --help            show this help message and exit
  --enter-once
  --no-stream
  --style {creative,balanced,precise}
  --cookie-file COOKIE_FILE

开发人员演示

传入饼干的三种方式:

  • 环境变量:。

    export COOKIE_FILE=/path/to/cookies.json

  • 在参数中指定路径,如下所示:

    cookies.json
    cookiePath

    bot = Chatbot(cookiePath='./cookie.json')
  • 直接通过参数传入 cookie ,如下所示:

    cookies

    with open('./cookie.json', 'r') as f:
        cookies = json.load(f)
    bot = Chatbot(cookies=cookies)

使用异步获得最佳体验

更高级用法示例的参考代码:

import asyncio
from EdgeGPT import Chatbot, ConversationStyle

async def main():
    bot = Chatbot()
    print(await bot.ask(prompt="Hello world", conversation_style=ConversationStyle.creative))
    await bot.close()


if __name__ == "__main__":
    asyncio.run(main())

进行中的工作

  • 错误处理

明星历史

星史图表

贡献

这个项目的存在要归功于所有做出贡献的人。