Antonio Cheong commited on
Commit
62fedbb
·
1 Parent(s): 8df309b
Files changed (2) hide show
  1. README.md +15 -15
  2. src/EdgeGPT.py +8 -3
README.md CHANGED
@@ -14,7 +14,7 @@
14
  <img alt="Python version" src="https://img.shields.io/badge/python-3.7+-blue.svg">
15
  </p>
16
 
17
- #
18
 
19
  > ### UPDATE 2023/02/13 - Public access shut down by Microsoft
20
  > ### UPDATE 2023/02/14 - Do not use for now while I verify its safety
@@ -42,10 +42,10 @@
42
  ```bash
43
  python3 -m pip install EdgeGPT --upgrade
44
  ```
45
-
46
- ### Requirements
47
  We have a shared token for public use. If you have your own account with access, you can use that instead.
48
-
49
  - python 3.7+
50
  - Microsoft Edge (Required)
51
  - 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,
53
 
54
  <details>
55
  <summary>
56
-
57
  ### Checking access (Required)
58
-
59
  </summary>
60
-
61
  - Install the latest version of Microsoft Edge
62
  - Open http://bing.com/chat
63
  - If you see a chat feature, you are good to go
64
-
65
  </details>
66
 
67
 
68
  <details>
69
  <summary>
70
-
71
  ### Getting authentication (Required)
72
-
73
  </summary>
74
 
75
  - 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,
77
  - Open the extension
78
  - Click "Export" on the bottom right (This saves your cookies to clipboard)
79
  - Paste your cookies into a file `cookies.json`
80
-
81
  </details>
82
 
83
 
@@ -85,9 +85,9 @@ We have a shared token for public use. If you have your own account with access,
85
  ## Usage
86
 
87
  ### Quick start
88
-
89
  ```
90
- $ python3 -m EdgeGPT -h
91
 
92
  EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
93
  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,
97
 
98
  Type !exit to exit
99
  Enter twice to send message
100
-
101
  usage: EdgeGPT.py [-h] [--no-stream] --cookie-file COOKIE_FILE
102
 
103
  options:
@@ -138,7 +138,7 @@ if __name__ == "__main__":
138
 
139
 
140
  ## Contributors
141
- This project exists thanks to all the people who contribute.
142
 
143
  <a href="https://github.com/acheong08/EdgeGPT/graphs/contributors">
144
  <img src="https://contrib.rocks/image?repo=acheong08/EdgeGPT" />
 
14
  <img alt="Python version" src="https://img.shields.io/badge/python-3.7+-blue.svg">
15
  </p>
16
 
17
+ #
18
 
19
  > ### UPDATE 2023/02/13 - Public access shut down by Microsoft
20
  > ### UPDATE 2023/02/14 - Do not use for now while I verify its safety
 
42
  ```bash
43
  python3 -m pip install EdgeGPT --upgrade
44
  ```
45
+
46
+ ### Requirements
47
  We have a shared token for public use. If you have your own account with access, you can use that instead.
48
+
49
  - python 3.7+
50
  - Microsoft Edge (Required)
51
  - A Microsoft Account with early access to http://bing.com/chat (Required)
 
53
 
54
  <details>
55
  <summary>
56
+
57
  ### Checking access (Required)
58
+
59
  </summary>
60
+
61
  - Install the latest version of Microsoft Edge
62
  - Open http://bing.com/chat
63
  - If you see a chat feature, you are good to go
64
+
65
  </details>
66
 
67
 
68
  <details>
69
  <summary>
70
+
71
  ### Getting authentication (Required)
72
+
73
  </summary>
74
 
75
  - 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
  - Open the extension
78
  - Click "Export" on the bottom right (This saves your cookies to clipboard)
79
  - Paste your cookies into a file `cookies.json`
80
+
81
  </details>
82
 
83
 
 
85
  ## Usage
86
 
87
  ### Quick start
88
+
89
  ```
90
+ $ python3 -m EdgeGPT -h
91
 
92
  EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
93
  Repo: github.com/acheong08/EdgeGPT
 
97
 
98
  Type !exit to exit
99
  Enter twice to send message
100
+
101
  usage: EdgeGPT.py [-h] [--no-stream] --cookie-file COOKIE_FILE
102
 
103
  options:
 
138
 
139
 
140
  ## Contributors
141
+ This project exists thanks to all the people who contribute.
142
 
143
  <a href="https://github.com/acheong08/EdgeGPT/graphs/contributors">
144
  <img src="https://contrib.rocks/image?repo=acheong08/EdgeGPT" />
src/EdgeGPT.py CHANGED
@@ -6,7 +6,8 @@ import asyncio
6
  import json
7
  import os
8
  import sys
9
- from typing import Generator, Optional
 
10
 
11
  import tls_client
12
  import websockets.client as websockets
@@ -22,6 +23,7 @@ HEADERS = {
22
  "referer": "https://www.bing.com/",
23
  "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
24
  "sec-ch-ua-platform": "Windows",
 
25
  }
26
 
27
 
@@ -110,7 +112,7 @@ class Conversation:
110
  }
111
  self.session = tls_client.Session(client_identifier="chrome_108")
112
  cookie_file = json.loads(
113
- open(os.environ.get("COOKIE_FILE"), "r", encoding="utf-8").read()
114
  )
115
  for cookie in cookie_file:
116
  self.session.cookies.set(cookie["name"], cookie["value"])
@@ -322,7 +324,10 @@ if __name__ == "__main__":
322
  parser = argparse.ArgumentParser()
323
  parser.add_argument("--no-stream", action="store_true")
324
  parser.add_argument(
325
- "--cookie-file", type=str, default="cookies.json", required=True
 
 
 
326
  )
327
  args = parser.parse_args()
328
  os.environ["COOKIE_FILE"] = args.cookie_file
 
6
  import json
7
  import os
8
  import sys
9
+ from typing import Generator
10
+ from typing import Optional
11
 
12
  import tls_client
13
  import websockets.client as websockets
 
23
  "referer": "https://www.bing.com/",
24
  "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
25
  "sec-ch-ua-platform": "Windows",
26
+ "x-forwarded-for": "8.8.8.8",
27
  }
28
 
29
 
 
112
  }
113
  self.session = tls_client.Session(client_identifier="chrome_108")
114
  cookie_file = json.loads(
115
+ open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read(),
116
  )
117
  for cookie in cookie_file:
118
  self.session.cookies.set(cookie["name"], cookie["value"])
 
324
  parser = argparse.ArgumentParser()
325
  parser.add_argument("--no-stream", action="store_true")
326
  parser.add_argument(
327
+ "--cookie-file",
328
+ type=str,
329
+ default="cookies.json",
330
+ required=True,
331
  )
332
  args = parser.parse_args()
333
  os.environ["COOKIE_FILE"] = args.cookie_file