From 62fedbb82dcf0ba1243b03c4afe679275bb23477 Mon Sep 17 00:00:00 2001
From: Antonio Cheong
Date: Thu, 16 Feb 2023 00:50:01 +0800
Subject: [PATCH] Fix #46
---
README.md | 30 +++++++++++++++---------------
src/EdgeGPT.py | 11 ++++++++---
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index 273230d0cd..ffdb6f0331 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
-#
+#
> ### UPDATE 2023/02/13 - Public access shut down by Microsoft
> ### UPDATE 2023/02/14 - Do not use for now while I verify its safety
@@ -42,10 +42,10 @@
```bash
python3 -m pip install EdgeGPT --upgrade
```
-
-### Requirements
+
+### Requirements
We have a shared token for public use. If you have your own account with access, you can use that instead.
-
+
- python 3.7+
- Microsoft Edge (Required)
- A Microsoft Account with early access to http://bing.com/chat (Required)
@@ -53,23 +53,23 @@ We have a shared token for public use. If you have your own account with access,
-
+
### Checking access (Required)
-
+
-
+
- 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 (Required)
-
+
- Install the cookie editor extension for [Chrome](https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookie-editor/)
@@ -77,7 +77,7 @@ We have a shared token for public use. If you have your own account with access,
- Open the extension
- Click "Export" on the bottom right (This saves your cookies to clipboard)
- Paste your cookies into a file `cookies.json`
-
+
@@ -85,9 +85,9 @@ We have a shared token for public use. If you have your own account with access,
## Usage
### Quick start
-
+
```
- $ python3 -m EdgeGPT -h
+ $ python3 -m EdgeGPT -h
EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
Repo: github.com/acheong08/EdgeGPT
@@ -97,7 +97,7 @@ We have a shared token for public use. If you have your own account with access,
Type !exit to exit
Enter twice to send message
-
+
usage: EdgeGPT.py [-h] [--no-stream] --cookie-file COOKIE_FILE
options:
@@ -138,7 +138,7 @@ if __name__ == "__main__":
## Contributors
-This project exists thanks to all the people who contribute.
+This project exists thanks to all the people who contribute.
diff --git a/src/EdgeGPT.py b/src/EdgeGPT.py
index c900d49f88..f8a4edf9c6 100644
--- a/src/EdgeGPT.py
+++ b/src/EdgeGPT.py
@@ -6,7 +6,8 @@
import json
import os
import sys
-from typing import Generator, Optional
+from typing import Generator
+from typing import Optional
import tls_client
import websockets.client as websockets
@@ -22,6 +23,7 @@
"referer": "https://www.bing.com/",
"sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
"sec-ch-ua-platform": "Windows",
+ "x-forwarded-for": "8.8.8.8",
}
@@ -110,7 +112,7 @@ def __init__(self) -> None:
}
self.session = tls_client.Session(client_identifier="chrome_108")
cookie_file = json.loads(
- open(os.environ.get("COOKIE_FILE"), "r", encoding="utf-8").read()
+ open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read(),
)
for cookie in cookie_file:
self.session.cookies.set(cookie["name"], cookie["value"])
@@ -322,7 +324,10 @@ async def main():
parser = argparse.ArgumentParser()
parser.add_argument("--no-stream", action="store_true")
parser.add_argument(
- "--cookie-file", type=str, default="cookies.json", required=True
+ "--cookie-file",
+ type=str,
+ default="cookies.json",
+ required=True,
)
args = parser.parse_args()
os.environ["COOKIE_FILE"] = args.cookie_file