Skip to main content

Reverse engineered Edge Chat API

Project description

Edge GPT

ChatGPT with internet access

Requirements

Setup

Checking access

  • Install the latest version of Microsoft Edge
  • Open http://bing.com/chat
  • If you see a chat feature, you are good to go

Getting authentication

  • Open the developer tools (F12)
  • Go to the Application tab → Storage → Cookies
  • Find the cookie named "_U"
  • Copy the value of the cookie
  • Method 1
    • export BING_U="<COOKIE_VALUE>"
  • Method 2
    • Use it as command line argument later

Installation

  • python3 -m pip install EdgeGPT

Demo usage

  • If BING_U in environment variables: python3 -m EdgeGPT
  • Else: python3 -m EdgeGPT "<COOKIE_VALUE>"

Developer

Use Async for the best experience

import asyncio
from EdgeGPT import Chatbot

def get_input(prompt):
    """
    Multi-line input function
    """
    # Display the prompt
    print(prompt, end="")

    # Initialize an empty list to store the input lines
    lines = []

    # Read lines of input until the user enters an empty line
    while True:
        line = input()
        if line == "":
            break
        lines.append(line)

    # Join the lines, separated by newlines, and store the result
    user_input = "\n".join(lines)

    # Return the input
    return user_input


async def main():
    """
    Main function
    """
    print("Initializing...")
    bot = Chatbot()
    while True:
        prompt = get_input("\nYou:\n")
        if prompt == "!exit":
            break
        elif prompt == "!help":
            print(
                """
            !help - Show this help message
            !exit - Exit the program
            !reset - Reset the conversation
            """,
            )
            continue
        elif prompt == "!reset":
            await bot.reset()
            continue
        print("Bot:")
        print(
            (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
                "body"
            ][0]["text"],
        )
    await bot.close()


if __name__ == "__main__":
    print(
        """
        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
    """,
    )
    asyncio.run(main())

Work in progress

  • Response streaming (Easily achievable)
  • Error handling

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

EdgeGPT-0.0.5.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

EdgeGPT-0.0.5-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file EdgeGPT-0.0.5.tar.gz.

File metadata

  • Download URL: EdgeGPT-0.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for EdgeGPT-0.0.5.tar.gz
Algorithm Hash digest
SHA256 5561518a87808fe7c678e56cf3494f3d4e45b35e861131733569d520f4cd4568
MD5 cfcfd9700ba71bc8e3332503adfc3232
BLAKE2b-256 d88f959fccae434e27643e9bd4f410bb77b2442f542fd0c09bf8bec0f3952c5d

See more details on using hashes here.

File details

Details for the file EdgeGPT-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: EdgeGPT-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for EdgeGPT-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 52371ead589d31289e88dc631c4a04db72e511b2e0f305b3befe987931d2bc2a
MD5 cd4f106146e33b09be1f2ceabd8fdbe3
BLAKE2b-256 28552ca3637ee6156020d03e2c0a2367d0aa1ff66c11825a27822d8e7019549b

See more details on using hashes here.

Supported by

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