Not-Grim-Refer commited on
Commit
d4cc99b
1 Parent(s): f93f95c

Upload 7 files

Browse files
Files changed (7) hide show
  1. .gitattributes +0 -1
  2. EdgeGPT.py +1293 -0
  3. README.md +8 -7
  4. app.py +46 -0
  5. cookies.json +364 -0
  6. gitattributes.txt +34 -0
  7. requirements.txt +13 -0
.gitattributes CHANGED
@@ -25,7 +25,6 @@
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
  *.wasm filter=lfs diff=lfs merge=lfs -text
 
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
28
  *.tflite filter=lfs diff=lfs merge=lfs -text
29
  *.tgz filter=lfs diff=lfs merge=lfs -text
30
  *.wasm filter=lfs diff=lfs merge=lfs -text
EdgeGPT.py ADDED
@@ -0,0 +1,1293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Main.py
3
+ """
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import asyncio
8
+ import aiofiles
9
+ import json
10
+ import os
11
+ import random
12
+ import re
13
+ import ssl
14
+ import sys
15
+ import time
16
+ import uuid
17
+ from enum import Enum
18
+ from pathlib import Path
19
+ from typing import Generator
20
+
21
+ try:
22
+ from typing import Literal
23
+ except ImportError:
24
+ from typing_extensions import Literal
25
+ from typing import Optional
26
+ from typing import Union
27
+
28
+ import aiohttp
29
+ import certifi
30
+ import httpx
31
+ from BingImageCreator import ImageGen
32
+ from BingImageCreator import ImageGenAsync
33
+ from prompt_toolkit import PromptSession
34
+ from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
35
+ from prompt_toolkit.completion import WordCompleter
36
+ from prompt_toolkit.history import InMemoryHistory
37
+ from prompt_toolkit.key_binding import KeyBindings
38
+ from rich.live import Live
39
+ from rich.markdown import Markdown
40
+
41
+ DELIMITER = "\x1e"
42
+
43
+
44
+ # Generate random IP between range 13.104.0.0/14
45
+ FORWARDED_IP = (
46
+ f"13.{random.randint(104, 107)}.{random.randint(0, 255)}.{random.randint(0, 255)}"
47
+ )
48
+
49
+ HEADERS = {
50
+ "accept": "application/json",
51
+ "accept-language": "en-US,en;q=0.9",
52
+ "content-type": "application/json",
53
+ "sec-ch-ua": '"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"',
54
+ "sec-ch-ua-arch": '"x86"',
55
+ "sec-ch-ua-bitness": '"64"',
56
+ "sec-ch-ua-full-version": '"109.0.1518.78"',
57
+ "sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
58
+ "sec-ch-ua-mobile": "?0",
59
+ "sec-ch-ua-model": "",
60
+ "sec-ch-ua-platform": '"Windows"',
61
+ "sec-ch-ua-platform-version": '"15.0.0"',
62
+ "sec-fetch-dest": "empty",
63
+ "sec-fetch-mode": "cors",
64
+ "sec-fetch-site": "same-origin",
65
+ "x-ms-client-request-id": str(uuid.uuid4()),
66
+ "x-ms-useragent": "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32",
67
+ "Referer": "https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx",
68
+ "Referrer-Policy": "origin-when-cross-origin",
69
+ "x-forwarded-for": FORWARDED_IP,
70
+ }
71
+
72
+ HEADERS_INIT_CONVER = {
73
+ "authority": "edgeservices.bing.com",
74
+ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
75
+ "accept-language": "en-US,en;q=0.9",
76
+ "cache-control": "max-age=0",
77
+ "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"',
78
+ "sec-ch-ua-arch": '"x86"',
79
+ "sec-ch-ua-bitness": '"64"',
80
+ "sec-ch-ua-full-version": '"110.0.1587.69"',
81
+ "sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"',
82
+ "sec-ch-ua-mobile": "?0",
83
+ "sec-ch-ua-model": '""',
84
+ "sec-ch-ua-platform": '"Windows"',
85
+ "sec-ch-ua-platform-version": '"15.0.0"',
86
+ "sec-fetch-dest": "document",
87
+ "sec-fetch-mode": "navigate",
88
+ "sec-fetch-site": "none",
89
+ "sec-fetch-user": "?1",
90
+ "upgrade-insecure-requests": "1",
91
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69",
92
+ "x-edge-shopping-flag": "1",
93
+ "x-forwarded-for": FORWARDED_IP,
94
+ }
95
+
96
+ ssl_context = ssl.create_default_context()
97
+ ssl_context.load_verify_locations(certifi.where())
98
+
99
+
100
+ class NotAllowedToAccess(Exception):
101
+ pass
102
+
103
+
104
+ class LocationHint(Enum):
105
+ USA = {
106
+ "locale": "en-US",
107
+ "LocationHint": [
108
+ {
109
+ "country": "United States",
110
+ "state": "California",
111
+ "city": "Los Angeles",
112
+ "timezoneoffset": 8,
113
+ "countryConfidence": 8,
114
+ "Center": {
115
+ "Latitude": 34.0536909,
116
+ "Longitude": -118.242766,
117
+ },
118
+ "RegionType": 2,
119
+ "SourceType": 1,
120
+ }
121
+ ],
122
+ }
123
+ CHINA = {
124
+ "locale": "zh-CN",
125
+ "LocationHint": [
126
+ {
127
+ "country": "China",
128
+ "state": "",
129
+ "city": "Beijing",
130
+ "timezoneoffset": 8,
131
+ "countryConfidence": 8,
132
+ "Center": {
133
+ "Latitude": 39.9042,
134
+ "Longitude": 116.4074,
135
+ },
136
+ "RegionType": 2,
137
+ "SourceType": 1,
138
+ }
139
+ ],
140
+ }
141
+ EU = {
142
+ "locale": "en-IE",
143
+ "LocationHint": [
144
+ {
145
+ "country": "Norway",
146
+ "state": "",
147
+ "city": "Oslo",
148
+ "timezoneoffset": 1,
149
+ "countryConfidence": 8,
150
+ "Center": {
151
+ "Latitude": 59.9139,
152
+ "Longitude": 10.7522,
153
+ },
154
+ "RegionType": 2,
155
+ "SourceType": 1,
156
+ }
157
+ ],
158
+ }
159
+ UK = {
160
+ "locale": "en-GB",
161
+ "LocationHint": [
162
+ {
163
+ "country": "United Kingdom",
164
+ "state": "",
165
+ "city": "London",
166
+ "timezoneoffset": 0,
167
+ "countryConfidence": 8,
168
+ "Center": {
169
+ "Latitude": 51.5074,
170
+ "Longitude": -0.1278,
171
+ },
172
+ "RegionType": 2,
173
+ "SourceType": 1,
174
+ },
175
+ ],
176
+ }
177
+
178
+
179
+ LOCATION_HINT_TYPES = Optional[Union[LocationHint, Literal["USA", "CHINA", "EU", "UK"]]]
180
+
181
+
182
+ def get_location_hint_from_locale(locale: str) -> dict | None:
183
+ locale = locale.lower()
184
+ if locale == "en-us":
185
+ return LocationHint.USA.value
186
+ elif locale == "zh-cn":
187
+ return LocationHint.CHINA.value
188
+ elif locale == "en-gb":
189
+ return LocationHint.UK.value
190
+ elif locale == "en-ie":
191
+ return LocationHint.EU.value
192
+ else:
193
+ return None
194
+
195
+
196
+ class ConversationStyle(Enum):
197
+ creative = [
198
+ "nlu_direct_response_filter",
199
+ "deepleo",
200
+ "disable_emoji_spoken_text",
201
+ "responsible_ai_policy_235",
202
+ "enablemm",
203
+ "h3imaginative",
204
+ "cachewriteext",
205
+ "e2ecachewrite",
206
+ "nodlcpcwrite",
207
+ "nointernalsugg",
208
+ "saharasugg",
209
+ "enablenewsfc",
210
+ "dv3sugg",
211
+ "clgalileo",
212
+ "gencontentv3",
213
+ "nojbfedge",
214
+ ]
215
+ balanced = [
216
+ "nlu_direct_response_filter",
217
+ "deepleo",
218
+ "disable_emoji_spoken_text",
219
+ "responsible_ai_policy_235",
220
+ "enablemm",
221
+ "harmonyv3",
222
+ "cachewriteext",
223
+ "e2ecachewrite",
224
+ "nodlcpcwrite",
225
+ "nointernalsugg",
226
+ "saharasugg",
227
+ "enablenewsfc",
228
+ "dv3sugg",
229
+ "nojbfedge",
230
+ ]
231
+ precise = [
232
+ "nlu_direct_response_filter",
233
+ "deepleo",
234
+ "disable_emoji_spoken_text",
235
+ "responsible_ai_policy_235",
236
+ "enablemm",
237
+ "h3precise",
238
+ "cachewriteext",
239
+ "e2ecachewrite",
240
+ "nodlcpcwrite",
241
+ "nointernalsugg",
242
+ "saharasugg",
243
+ "enablenewsfc",
244
+ "dv3sugg",
245
+ "clgalileo",
246
+ "gencontentv3",
247
+ "nojbfedge",
248
+ ]
249
+
250
+
251
+ CONVERSATION_STYLE_TYPE = Optional[
252
+ Union[ConversationStyle, Literal["creative", "balanced", "precise"]]
253
+ ]
254
+
255
+
256
+ def _append_identifier(msg: dict) -> str:
257
+ """
258
+ Appends special character to end of message to identify end of message
259
+ """
260
+ # Convert dict to json string
261
+ return json.dumps(msg, ensure_ascii=False) + DELIMITER
262
+
263
+
264
+ def _get_ran_hex(length: int = 32) -> str:
265
+ """
266
+ Returns random hex string
267
+ """
268
+ return "".join(random.choice("0123456789abcdef") for _ in range(length))
269
+
270
+
271
+ class _ChatHubRequest:
272
+ """
273
+ Request object for ChatHub
274
+ """
275
+
276
+ def __init__(
277
+ self,
278
+ conversation_signature: str,
279
+ client_id: str,
280
+ conversation_id: str,
281
+ invocation_id: int = 0,
282
+ ) -> None:
283
+ self.struct: dict = {}
284
+
285
+ self.client_id: str = client_id
286
+ self.conversation_id: str = conversation_id
287
+ self.conversation_signature: str = conversation_signature
288
+ self.invocation_id: int = invocation_id
289
+
290
+ def update(
291
+ self,
292
+ prompt: str,
293
+ conversation_style: CONVERSATION_STYLE_TYPE,
294
+ options: list | None = None,
295
+ webpage_context: str | None = None,
296
+ search_result: bool = False,
297
+ locale: str = "en-US",
298
+ ) -> None:
299
+ """
300
+ Updates request object
301
+ """
302
+ if options is None:
303
+ options = [
304
+ "deepleo",
305
+ "enable_debug_commands",
306
+ "disable_emoji_spoken_text",
307
+ "enablemm",
308
+ ]
309
+ if conversation_style:
310
+ if not isinstance(conversation_style, ConversationStyle):
311
+ conversation_style = getattr(ConversationStyle, conversation_style)
312
+ options = conversation_style.value
313
+ self.struct = {
314
+ "arguments": [
315
+ {
316
+ "source": "cib",
317
+ "optionsSets": options,
318
+ "allowedMessageTypes": [
319
+ "Chat",
320
+ "Disengaged",
321
+ "AdsQuery",
322
+ "SemanticSerp",
323
+ "GenerateContentQuery",
324
+ "SearchQuery",
325
+ "ActionRequest",
326
+ "Context",
327
+ "Progress",
328
+ "AdsQuery",
329
+ "SemanticSerp",
330
+ ],
331
+ "sliceIds": [
332
+ "winmuid3tf",
333
+ "osbsdusgreccf",
334
+ "ttstmout",
335
+ "crchatrev",
336
+ "winlongmsgtf",
337
+ "ctrlworkpay",
338
+ "norespwtf",
339
+ "tempcacheread",
340
+ "temptacache",
341
+ "505scss0",
342
+ "508jbcars0",
343
+ "515enbotdets0",
344
+ "5082tsports",
345
+ "515vaoprvs",
346
+ "424dagslnv1s0",
347
+ "kcimgattcf",
348
+ "427startpms0",
349
+ ],
350
+ "traceId": _get_ran_hex(32),
351
+ "isStartOfSession": self.invocation_id == 0,
352
+ "message": {
353
+ "locale": locale,
354
+ "market": locale,
355
+ "region": locale[-2:], # en-US -> US
356
+ "locationHints": [get_location_hint_from_locale(locale)],
357
+ "author": "user",
358
+ "inputMethod": "Keyboard",
359
+ "text": prompt,
360
+ "messageType": "Chat",
361
+ },
362
+ "conversationSignature": self.conversation_signature,
363
+ "participant": {
364
+ "id": self.client_id,
365
+ },
366
+ "conversationId": self.conversation_id,
367
+ },
368
+ ],
369
+ "invocationId": str(self.invocation_id),
370
+ "target": "chat",
371
+ "type": 4,
372
+ }
373
+ if search_result:
374
+ have_search_result = [
375
+ "InternalSearchQuery",
376
+ "InternalSearchResult",
377
+ "InternalLoaderMessage",
378
+ "RenderCardRequest",
379
+ ]
380
+ self.struct["arguments"][0]["allowedMessageTypes"] += have_search_result
381
+ if webpage_context:
382
+ self.struct["arguments"][0]["previousMessages"] = [
383
+ {
384
+ "author": "user",
385
+ "description": webpage_context,
386
+ "contextType": "WebPage",
387
+ "messageType": "Context",
388
+ "messageId": "discover-web--page-ping-mriduna-----",
389
+ },
390
+ ]
391
+ self.invocation_id += 1
392
+
393
+
394
+ class _Conversation:
395
+ """
396
+ Conversation API
397
+ """
398
+
399
+ def __init__(
400
+ self,
401
+ proxy: str | None = None,
402
+ async_mode: bool = False,
403
+ cookies: list[dict] | None = None,
404
+ ) -> None:
405
+ if async_mode:
406
+ return
407
+ self.struct: dict = {
408
+ "conversationId": None,
409
+ "clientId": None,
410
+ "conversationSignature": None,
411
+ "result": {"value": "Success", "message": None},
412
+ }
413
+ self.proxy = proxy
414
+ proxy = (
415
+ proxy
416
+ or os.environ.get("all_proxy")
417
+ or os.environ.get("ALL_PROXY")
418
+ or os.environ.get("https_proxy")
419
+ or os.environ.get("HTTPS_PROXY")
420
+ or None
421
+ )
422
+ if proxy is not None and proxy.startswith("socks5h://"):
423
+ proxy = "socks5://" + proxy[len("socks5h://") :]
424
+ self.session = httpx.Client(
425
+ proxies=proxy,
426
+ timeout=900,
427
+ headers=HEADERS_INIT_CONVER,
428
+ )
429
+ if cookies:
430
+ for cookie in cookies:
431
+ self.session.cookies.set(cookie["name"], cookie["value"])
432
+ # Send GET request
433
+ response = self.session.get(
434
+ url=os.environ.get("BING_PROXY_URL")
435
+ or "https://edgeservices.bing.com/edgesvc/turing/conversation/create",
436
+ )
437
+ if response.status_code != 200:
438
+ response = self.session.get(
439
+ "https://edge.churchless.tech/edgesvc/turing/conversation/create",
440
+ )
441
+ if response.status_code != 200:
442
+ print(f"Status code: {response.status_code}")
443
+ print(response.text)
444
+ print(response.url)
445
+ raise Exception("Authentication failed")
446
+ try:
447
+ self.struct = response.json()
448
+ except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc:
449
+ raise Exception(
450
+ "Authentication failed. You have not been accepted into the beta.",
451
+ ) from exc
452
+ if self.struct["result"]["value"] == "UnauthorizedRequest":
453
+ raise NotAllowedToAccess(self.struct["result"]["message"])
454
+
455
+ @staticmethod
456
+ async def create(
457
+ proxy: str | None = None,
458
+ cookies: list[dict] | None = None,
459
+ ) -> _Conversation:
460
+ self = _Conversation(async_mode=True)
461
+ self.struct = {
462
+ "conversationId": None,
463
+ "clientId": None,
464
+ "conversationSignature": None,
465
+ "result": {"value": "Success", "message": None},
466
+ }
467
+ self.proxy = proxy
468
+ proxy = (
469
+ proxy
470
+ or os.environ.get("all_proxy")
471
+ or os.environ.get("ALL_PROXY")
472
+ or os.environ.get("https_proxy")
473
+ or os.environ.get("HTTPS_PROXY")
474
+ or None
475
+ )
476
+ if proxy is not None and proxy.startswith("socks5h://"):
477
+ proxy = "socks5://" + proxy[len("socks5h://") :]
478
+ transport = httpx.AsyncHTTPTransport(retries=900)
479
+ # Convert cookie format to httpx format
480
+ formatted_cookies = None
481
+ if cookies:
482
+ formatted_cookies = httpx.Cookies()
483
+ for cookie in cookies:
484
+ formatted_cookies.set(cookie["name"], cookie["value"])
485
+ async with httpx.AsyncClient(
486
+ proxies=proxy,
487
+ timeout=30,
488
+ headers=HEADERS_INIT_CONVER,
489
+ transport=transport,
490
+ cookies=formatted_cookies,
491
+ ) as client:
492
+ # Send GET request
493
+ response = await client.get(
494
+ url=os.environ.get("BING_PROXY_URL")
495
+ or "https://edgeservices.bing.com/edgesvc/turing/conversation/create",
496
+ )
497
+ if response.status_code != 200:
498
+ response = await client.get(
499
+ "https://edge.churchless.tech/edgesvc/turing/conversation/create",
500
+ )
501
+ if response.status_code != 200:
502
+ print(f"Status code: {response.status_code}")
503
+ print(response.text)
504
+ print(response.url)
505
+ raise Exception("Authentication failed")
506
+ try:
507
+ self.struct = response.json()
508
+ except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc:
509
+ raise Exception(
510
+ "Authentication failed. You have not been accepted into the beta.",
511
+ ) from exc
512
+ if self.struct["result"]["value"] == "UnauthorizedRequest":
513
+ raise NotAllowedToAccess(self.struct["result"]["message"])
514
+ return self
515
+
516
+
517
+ class _ChatHub:
518
+ """
519
+ Chat API
520
+ """
521
+
522
+ def __init__(
523
+ self,
524
+ conversation: _Conversation,
525
+ proxy: str = None,
526
+ cookies: list[dict] | None = None,
527
+ ) -> None:
528
+ self.session: aiohttp.ClientSession | None = None
529
+ self.wss: aiohttp.ClientWebSocketResponse | None = None
530
+ self.request: _ChatHubRequest
531
+ self.loop: bool
532
+ self.task: asyncio.Task
533
+ self.request = _ChatHubRequest(
534
+ conversation_signature=conversation.struct["conversationSignature"],
535
+ client_id=conversation.struct["clientId"],
536
+ conversation_id=conversation.struct["conversationId"],
537
+ )
538
+ self.cookies = cookies
539
+ self.proxy: str = proxy
540
+
541
+ async def ask_stream(
542
+ self,
543
+ prompt: str,
544
+ wss_link: str,
545
+ conversation_style: CONVERSATION_STYLE_TYPE = None,
546
+ raw: bool = False,
547
+ options: dict = None,
548
+ webpage_context: str | None = None,
549
+ search_result: bool = False,
550
+ locale: str = "en-US",
551
+ ) -> Generator[str, None, None]:
552
+ """
553
+ Ask a question to the bot
554
+ """
555
+ timeout = aiohttp.ClientTimeout(total=900)
556
+ self.session = aiohttp.ClientSession(timeout=timeout)
557
+
558
+ if self.wss and not self.wss.closed:
559
+ await self.wss.close()
560
+ # Check if websocket is closed
561
+ self.wss = await self.session.ws_connect(
562
+ wss_link,
563
+ headers=HEADERS,
564
+ ssl=ssl_context,
565
+ proxy=self.proxy,
566
+ autoping=False,
567
+ )
568
+ await self._initial_handshake()
569
+ if self.request.invocation_id == 0:
570
+ # Construct a ChatHub request
571
+ self.request.update(
572
+ prompt=prompt,
573
+ conversation_style=conversation_style,
574
+ options=options,
575
+ webpage_context=webpage_context,
576
+ search_result=search_result,
577
+ locale=locale,
578
+ )
579
+ else:
580
+ async with httpx.AsyncClient() as client:
581
+ response = await client.post(
582
+ "https://sydney.bing.com/sydney/UpdateConversation/",
583
+ json={
584
+ "messages": [
585
+ {
586
+ "author": "user",
587
+ "description": webpage_context,
588
+ "contextType": "WebPage",
589
+ "messageType": "Context",
590
+ },
591
+ ],
592
+ "conversationId": self.request.conversation_id,
593
+ "source": "cib",
594
+ "traceId": _get_ran_hex(32),
595
+ "participant": {"id": self.request.client_id},
596
+ "conversationSignature": self.request.conversation_signature,
597
+ },
598
+ )
599
+ if response.status_code != 200:
600
+ print(f"Status code: {response.status_code}")
601
+ print(response.text)
602
+ print(response.url)
603
+ raise Exception("Update web page context failed")
604
+ # Construct a ChatHub request
605
+ self.request.update(
606
+ prompt=prompt,
607
+ conversation_style=conversation_style,
608
+ options=options,
609
+ )
610
+ # Send request
611
+ await self.wss.send_str(_append_identifier(self.request.struct))
612
+ final = False
613
+ draw = False
614
+ resp_txt = ""
615
+ result_text = ""
616
+ resp_txt_no_link = ""
617
+ while not final:
618
+ msg = await self.wss.receive(timeout=900)
619
+ objects = msg.data.split(DELIMITER)
620
+ for obj in objects:
621
+ if obj is None or not obj:
622
+ continue
623
+ response = json.loads(obj)
624
+ if response.get("type") != 2 and raw:
625
+ yield False, response
626
+ elif response.get("type") == 1 and response["arguments"][0].get(
627
+ "messages",
628
+ ):
629
+ if not draw:
630
+ if (
631
+ response["arguments"][0]["messages"][0].get("messageType")
632
+ == "GenerateContentQuery"
633
+ ):
634
+ async with ImageGenAsync("", True) as image_generator:
635
+ images = await image_generator.get_images(
636
+ response["arguments"][0]["messages"][0]["text"],
637
+ )
638
+ for i, image in enumerate(images):
639
+ resp_txt = resp_txt + f"\n![image{i}]({image})"
640
+ draw = True
641
+ if (
642
+ response["arguments"][0]["messages"][0]["contentOrigin"]
643
+ != "Apology"
644
+ ) and not draw:
645
+ resp_txt = result_text + response["arguments"][0][
646
+ "messages"
647
+ ][0]["adaptiveCards"][0]["body"][0].get("text", "")
648
+ resp_txt_no_link = result_text + response["arguments"][0][
649
+ "messages"
650
+ ][0].get("text", "")
651
+ if response["arguments"][0]["messages"][0].get(
652
+ "messageType",
653
+ ):
654
+ resp_txt = (
655
+ resp_txt
656
+ + response["arguments"][0]["messages"][0][
657
+ "adaptiveCards"
658
+ ][0]["body"][0]["inlines"][0].get("text")
659
+ + "\n"
660
+ )
661
+ result_text = (
662
+ result_text
663
+ + response["arguments"][0]["messages"][0][
664
+ "adaptiveCards"
665
+ ][0]["body"][0]["inlines"][0].get("text")
666
+ + "\n"
667
+ )
668
+ yield False, resp_txt
669
+
670
+ elif response.get("type") == 2:
671
+ if response["item"]["result"].get("error"):
672
+ await self.close()
673
+ raise Exception(
674
+ f"{response['item']['result']['value']}: {response['item']['result']['message']}",
675
+ )
676
+ if draw:
677
+ cache = response["item"]["messages"][1]["adaptiveCards"][0][
678
+ "body"
679
+ ][0]["text"]
680
+ response["item"]["messages"][1]["adaptiveCards"][0]["body"][0][
681
+ "text"
682
+ ] = (cache + resp_txt)
683
+ if (
684
+ response["item"]["messages"][-1]["contentOrigin"] == "Apology"
685
+ and resp_txt
686
+ ):
687
+ response["item"]["messages"][-1]["text"] = resp_txt_no_link
688
+ response["item"]["messages"][-1]["adaptiveCards"][0]["body"][0][
689
+ "text"
690
+ ] = resp_txt
691
+ print(
692
+ "Preserved the message from being deleted",
693
+ file=sys.stderr,
694
+ )
695
+ final = True
696
+ await self.close()
697
+ yield True, response
698
+
699
+ async def _initial_handshake(self) -> None:
700
+ await self.wss.send_str(_append_identifier({"protocol": "json", "version": 1}))
701
+ await self.wss.receive(timeout=900)
702
+
703
+ async def close(self) -> None:
704
+ """
705
+ Close the connection
706
+ """
707
+ if self.wss and not self.wss.closed:
708
+ await self.wss.close()
709
+ if self.session and not self.session.closed:
710
+ await self.session.close()
711
+
712
+
713
+ class Chatbot:
714
+ """
715
+ Combines everything to make it seamless
716
+ """
717
+
718
+ def __init__(
719
+ self,
720
+ proxy: str | None = None,
721
+ cookies: list[dict] | None = None,
722
+ ) -> None:
723
+ self.proxy: str | None = proxy
724
+ self.chat_hub: _ChatHub = _ChatHub(
725
+ _Conversation(self.proxy, cookies=cookies),
726
+ proxy=self.proxy,
727
+ cookies=cookies,
728
+ )
729
+
730
+ @staticmethod
731
+ async def create(
732
+ proxy: str | None = None,
733
+ cookies: list[dict] | None = None,
734
+ ):
735
+ self = Chatbot.__new__(Chatbot)
736
+ self.proxy = proxy
737
+ self.chat_hub = _ChatHub(
738
+ await _Conversation.create(self.proxy, cookies=cookies),
739
+ proxy=self.proxy,
740
+ cookies=cookies,
741
+ )
742
+ return self
743
+
744
+ async def save_conversation(self, filename: str) -> None:
745
+ """
746
+ Save the conversation to a file
747
+ """
748
+ async with aiofiles.open(filename, "w") as f:
749
+ f.write(json.dumps(self.chat_hub.struct))
750
+
751
+ async def load_conversation(self, filename: str) -> None:
752
+ """
753
+ Load the conversation from a file
754
+ """
755
+ async with aiofiles.open(filename, "r") as f:
756
+ self.chat_hub.struct = json.loads(await f.read())
757
+
758
+ async def ask(
759
+ self,
760
+ prompt: str,
761
+ wss_link: str = "wss://sydney.bing.com/sydney/ChatHub",
762
+ conversation_style: CONVERSATION_STYLE_TYPE = None,
763
+ options: dict = None,
764
+ webpage_context: str | None = None,
765
+ search_result: bool = False,
766
+ locale: str = "en-US",
767
+ ) -> dict:
768
+ """
769
+ Ask a question to the bot
770
+ """
771
+ async for final, response in self.chat_hub.ask_stream(
772
+ prompt=prompt,
773
+ conversation_style=conversation_style,
774
+ wss_link=wss_link,
775
+ options=options,
776
+ webpage_context=webpage_context,
777
+ search_result=search_result,
778
+ locale=locale,
779
+ ):
780
+ if final:
781
+ return response
782
+ await self.chat_hub.wss.close()
783
+ return {}
784
+
785
+ async def ask_stream(
786
+ self,
787
+ prompt: str,
788
+ wss_link: str = "wss://sydney.bing.com/sydney/ChatHub",
789
+ conversation_style: CONVERSATION_STYLE_TYPE = None,
790
+ raw: bool = False,
791
+ options: dict = None,
792
+ webpage_context: str | None = None,
793
+ search_result: bool = False,
794
+ locale: str = "en-US",
795
+ ) -> Generator[str, None, None]:
796
+ """
797
+ Ask a question to the bot
798
+ """
799
+ async for response in self.chat_hub.ask_stream(
800
+ prompt=prompt,
801
+ conversation_style=conversation_style,
802
+ wss_link=wss_link,
803
+ raw=raw,
804
+ options=options,
805
+ webpage_context=webpage_context,
806
+ search_result=search_result,
807
+ locale=locale,
808
+ ):
809
+ yield response
810
+
811
+ async def close(self) -> None:
812
+ """
813
+ Close the connection
814
+ """
815
+ await self.chat_hub.close()
816
+
817
+ async def reset(self) -> None:
818
+ """
819
+ Reset the conversation
820
+ """
821
+ await self.close()
822
+ self.chat_hub = _ChatHub(
823
+ await _Conversation.create(self.proxy, cookies=self.chat_hub.cookies),
824
+ proxy=self.proxy,
825
+ cookies=self.chat_hub.cookies,
826
+ )
827
+
828
+
829
+ async def _get_input_async(
830
+ session: PromptSession = None,
831
+ completer: WordCompleter = None,
832
+ ) -> str:
833
+ """
834
+ Multiline input function.
835
+ """
836
+ return await session.prompt_async(
837
+ completer=completer,
838
+ multiline=True,
839
+ auto_suggest=AutoSuggestFromHistory(),
840
+ )
841
+
842
+
843
+ def _create_session() -> PromptSession:
844
+ kb = KeyBindings()
845
+
846
+ @kb.add("enter")
847
+ def _(event):
848
+ buffer_text = event.current_buffer.text
849
+ if buffer_text.startswith("!"):
850
+ event.current_buffer.validate_and_handle()
851
+ else:
852
+ event.current_buffer.insert_text("\n")
853
+
854
+ @kb.add("escape")
855
+ def _(event):
856
+ if event.current_buffer.complete_state:
857
+ # event.current_buffer.cancel_completion()
858
+ event.current_buffer.text = ""
859
+
860
+ return PromptSession(key_bindings=kb, history=InMemoryHistory())
861
+
862
+
863
+ def _create_completer(commands: list, pattern_str: str = "$"):
864
+ return WordCompleter(words=commands, pattern=re.compile(pattern_str))
865
+
866
+
867
+ def _create_history_logger(f):
868
+ def logger(*args, **kwargs):
869
+ tmp = sys.stdout
870
+ sys.stdout = f
871
+ print(*args, **kwargs, flush=True)
872
+ sys.stdout = tmp
873
+
874
+ return logger
875
+
876
+
877
+ async def async_main(args: argparse.Namespace) -> None:
878
+ """
879
+ Main function
880
+ """
881
+ print("Initializing...")
882
+ print("Enter `alt+enter` or `escape+enter` to send a message")
883
+ # Read and parse cookies
884
+ cookies = None
885
+ if args.cookie_file:
886
+ cookies = json.loads(open(args.cookie_file, encoding="utf-8").read())
887
+ bot = await Chatbot.create(proxy=args.proxy, cookies=cookies)
888
+ session = _create_session()
889
+ completer = _create_completer(["!help", "!exit", "!reset"])
890
+ initial_prompt = args.prompt
891
+
892
+ # Log chat history
893
+ def p_hist(*args, **kwargs):
894
+ pass
895
+
896
+ if args.history_file:
897
+ f = open(args.history_file, "a+", encoding="utf-8")
898
+ p_hist = _create_history_logger(f)
899
+
900
+ while True:
901
+ print("\nYou:")
902
+ p_hist("\nYou:")
903
+ if initial_prompt:
904
+ question = initial_prompt
905
+ print(question)
906
+ initial_prompt = None
907
+ else:
908
+ question = (
909
+ input()
910
+ if args.enter_once
911
+ else await _get_input_async(session=session, completer=completer)
912
+ )
913
+ print()
914
+ p_hist(question + "\n")
915
+ if question == "!exit":
916
+ break
917
+ if question == "!help":
918
+ print(
919
+ """
920
+ !help - Show this help message
921
+ !exit - Exit the program
922
+ !reset - Reset the conversation
923
+ """,
924
+ )
925
+ continue
926
+ if question == "!reset":
927
+ await bot.reset()
928
+ continue
929
+ print("Bot:")
930
+ p_hist("Bot:")
931
+ if args.no_stream:
932
+ response = (
933
+ await bot.ask(
934
+ prompt=question,
935
+ conversation_style=args.style,
936
+ wss_link=args.wss_link,
937
+ search_result=args.search_result,
938
+ locale=args.locale,
939
+ )
940
+ )["item"]["messages"][1]["adaptiveCards"][0]["body"][0]["text"]
941
+ print(response)
942
+ p_hist(response)
943
+ else:
944
+ wrote = 0
945
+ if args.rich:
946
+ md = Markdown("")
947
+ with Live(md, auto_refresh=False) as live:
948
+ async for final, response in bot.ask_stream(
949
+ prompt=question,
950
+ conversation_style=args.style,
951
+ wss_link=args.wss_link,
952
+ search_result=args.search_result,
953
+ locale=args.locale,
954
+ ):
955
+ if not final:
956
+ if not wrote:
957
+ p_hist(response, end="")
958
+ else:
959
+ p_hist(response[wrote:], end="")
960
+ if wrote > len(response):
961
+ print(md)
962
+ print(Markdown("***Bing revoked the response.***"))
963
+ wrote = len(response)
964
+ md = Markdown(response)
965
+ live.update(md, refresh=True)
966
+ else:
967
+ async for final, response in bot.ask_stream(
968
+ prompt=question,
969
+ conversation_style=args.style,
970
+ wss_link=args.wss_link,
971
+ search_result=args.search_result,
972
+ locale=args.locale,
973
+ ):
974
+ if not final:
975
+ if not wrote:
976
+ print(response, end="", flush=True)
977
+ p_hist(response, end="")
978
+ else:
979
+ print(response[wrote:], end="", flush=True)
980
+ p_hist(response[wrote:], end="")
981
+ wrote = len(response)
982
+ print()
983
+ p_hist()
984
+ if args.history_file:
985
+ f.close()
986
+ await bot.close()
987
+
988
+
989
+ def main() -> None:
990
+ print(
991
+ """
992
+ EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
993
+ Repo: github.com/acheong08/EdgeGPT
994
+ By: Antonio Cheong
995
+
996
+ !help for help
997
+
998
+ Type !exit to exit
999
+ """,
1000
+ )
1001
+ parser = argparse.ArgumentParser()
1002
+ parser.add_argument("--enter-once", action="store_true")
1003
+ parser.add_argument("--search-result", action="store_true")
1004
+ parser.add_argument("--no-stream", action="store_true")
1005
+ parser.add_argument("--rich", action="store_true")
1006
+ parser.add_argument(
1007
+ "--proxy",
1008
+ help="Proxy URL (e.g. socks5://127.0.0.1:1080)",
1009
+ type=str,
1010
+ )
1011
+ parser.add_argument(
1012
+ "--wss-link",
1013
+ help="WSS URL(e.g. wss://sydney.bing.com/sydney/ChatHub)",
1014
+ type=str,
1015
+ default="wss://sydney.bing.com/sydney/ChatHub",
1016
+ )
1017
+ parser.add_argument(
1018
+ "--style",
1019
+ choices=["creative", "balanced", "precise"],
1020
+ default="balanced",
1021
+ )
1022
+ parser.add_argument(
1023
+ "--prompt",
1024
+ type=str,
1025
+ default="",
1026
+ required=False,
1027
+ help="prompt to start with",
1028
+ )
1029
+ parser.add_argument(
1030
+ "--cookie-file",
1031
+ type=str,
1032
+ default="",
1033
+ required=False,
1034
+ help="path to cookie file",
1035
+ )
1036
+ parser.add_argument(
1037
+ "--history-file",
1038
+ type=str,
1039
+ default="",
1040
+ required=False,
1041
+ help="path to history file",
1042
+ )
1043
+ parser.add_argument(
1044
+ "--locale",
1045
+ type=str,
1046
+ default="en-US",
1047
+ required=False,
1048
+ help="your locale",
1049
+ )
1050
+ args = parser.parse_args()
1051
+ asyncio.run(async_main(args))
1052
+
1053
+
1054
+ class Cookie:
1055
+ """
1056
+ Convenience class for Bing Cookie files, data, and configuration. This Class
1057
+ is updated dynamically by the Query class to allow cycling through >1
1058
+ cookie/credentials file e.g. when daily request limits (current 200 per
1059
+ account per day) are exceeded.
1060
+ """
1061
+
1062
+ current_file_index = 0
1063
+ dirpath = Path("./").resolve()
1064
+ search_pattern = "bing_cookies_*.json"
1065
+ ignore_files = set()
1066
+ current_filepath: dict | None = None
1067
+
1068
+ @classmethod
1069
+ def fetch_default(cls, path=None):
1070
+ from selenium import webdriver
1071
+ from selenium.webdriver.common.by import By
1072
+
1073
+ driver = webdriver.Edge()
1074
+ driver.get("https://bing.com/chat")
1075
+ time.sleep(5)
1076
+ xpath = '//button[@id="bnp_btn_accept"]'
1077
+ driver.find_element(By.XPATH, xpath).click()
1078
+ time.sleep(2)
1079
+ xpath = '//a[@id="codexPrimaryButton"]'
1080
+ driver.find_element(By.XPATH, xpath).click()
1081
+ if path is None:
1082
+ path = Path("./bing_cookies__default.json")
1083
+ # Double underscore ensures this file is first when sorted
1084
+ cookies = driver.get_cookies()
1085
+ Path(path).write_text(json.dumps(cookies, indent=4), encoding="utf-8")
1086
+ # Path again in case supplied path is: str
1087
+ print(f"Cookies saved to: {path}")
1088
+ driver.quit()
1089
+
1090
+ @classmethod
1091
+ def files(cls):
1092
+ """Return a sorted list of all cookie files matching .search_pattern"""
1093
+ all_files = set(cls.dirpath.glob(cls.search_pattern))
1094
+ return sorted(list(all_files - cls.ignore_files))
1095
+
1096
+ @classmethod
1097
+ def import_data(cls):
1098
+ """
1099
+ Read the active cookie file and populate the following attributes:
1100
+
1101
+ .current_filepath
1102
+ .current_data
1103
+ .image_token
1104
+ """
1105
+ try:
1106
+ cls.current_filepath = cls.files()[cls.current_file_index]
1107
+ except IndexError as exc:
1108
+ print(
1109
+ "> Please set Cookie.current_filepath to a valid cookie file, then run Cookie.import_data()",
1110
+ )
1111
+ raise "No valid cookie file found." from exc
1112
+ print(f"> Importing cookies from: {cls.current_filepath.name}")
1113
+ with open(cls.current_filepath, encoding="utf-8") as file:
1114
+ cls.current_data = json.load(file)
1115
+ cls.image_token = [x for x in cls.current_data if x.get("name") == "_U"]
1116
+ cls.image_token = cls.image_token[0].get("value")
1117
+
1118
+ @classmethod
1119
+ def import_next(cls):
1120
+ """
1121
+ Cycle through to the next cookies file. Import it. Mark the previous
1122
+ file to be ignored for the remainder of the current session.
1123
+ """
1124
+ cls.ignore_files.add(cls.current_filepath)
1125
+ if Cookie.current_file_index >= len(cls.files()):
1126
+ Cookie.current_file_index = 0
1127
+ Cookie.import_data()
1128
+
1129
+
1130
+ class Query:
1131
+ """
1132
+ A convenience class that wraps around EdgeGPT.Chatbot to encapsulate input,
1133
+ config, and output all together. Relies on Cookie class for authentication
1134
+ """
1135
+
1136
+ def __init__(
1137
+ self,
1138
+ prompt,
1139
+ style="precise",
1140
+ content_type="text",
1141
+ cookie_file=0,
1142
+ echo=True,
1143
+ echo_prompt=False,
1144
+ proxy: str | None = None,
1145
+ ):
1146
+ """
1147
+ Arguments:
1148
+
1149
+ prompt: Text to enter into Bing Chat
1150
+ style: creative, balanced, or precise
1151
+ content_type: "text" for Bing Chat; "image" for Dall-e
1152
+ cookie_file: Path, filepath string, or index (int) to list of cookie paths
1153
+ echo: Print something to confirm request made
1154
+ echo_prompt: Print confirmation of the evaluated prompt
1155
+ """
1156
+ self.proxy = proxy
1157
+ self.index = []
1158
+ self.request_count = {}
1159
+ self.image_dirpath = Path("./").resolve()
1160
+ Cookie.import_data()
1161
+ self.index += [self]
1162
+ self.prompt = prompt
1163
+ files = Cookie.files()
1164
+ if isinstance(cookie_file, int):
1165
+ index = cookie_file if cookie_file < len(files) else 0
1166
+ else:
1167
+ if not isinstance(cookie_file, (str, Path)):
1168
+ message = "'cookie_file' must be an int, str, or Path object"
1169
+ raise TypeError(message)
1170
+ cookie_file = Path(cookie_file)
1171
+ if cookie_file in files: # Supplied filepath IS in Cookie.dirpath
1172
+ index = files.index(cookie_file)
1173
+ else: # Supplied filepath is NOT in Cookie.dirpath
1174
+ if cookie_file.is_file():
1175
+ Cookie.dirpath = cookie_file.parent.resolve()
1176
+ if cookie_file.is_dir():
1177
+ Cookie.dirpath = cookie_file.resolve()
1178
+ index = 0
1179
+ Cookie.current_file_index = index
1180
+ if content_type == "text":
1181
+ self.style = style
1182
+ self.log_and_send_query(echo, echo_prompt)
1183
+ if content_type == "image":
1184
+ self.create_image()
1185
+
1186
+ def log_and_send_query(self, echo, echo_prompt):
1187
+ self.response = asyncio.run(self.send_to_bing(echo, echo_prompt))
1188
+ name = str(Cookie.current_filepath.name)
1189
+ if not self.request_count.get(name):
1190
+ self.request_count[name] = 1
1191
+ else:
1192
+ self.request_count[name] += 1
1193
+
1194
+ def create_image(self):
1195
+ image_generator = ImageGen(Cookie.image_token)
1196
+ image_generator.save_images(
1197
+ image_generator.get_images(self.prompt),
1198
+ output_dir=self.image_dirpath,
1199
+ )
1200
+
1201
+ async def send_to_bing(self, echo=True, echo_prompt=False):
1202
+ """Creat, submit, then close a Chatbot instance. Return the response"""
1203
+ retries = len(Cookie.files())
1204
+ while retries:
1205
+ try:
1206
+ # Read the cookies file
1207
+ bot = await Chatbot.create(
1208
+ proxy=self.proxy, cookies=Cookie.current_data
1209
+ )
1210
+ if echo_prompt:
1211
+ print(f"> {self.prompt}=")
1212
+ if echo:
1213
+ print("> Waiting for response...")
1214
+ if self.style.lower() not in "creative balanced precise".split():
1215
+ self.style = "precise"
1216
+ response = await bot.ask(
1217
+ prompt=self.prompt,
1218
+ conversation_style=getattr(ConversationStyle, self.style),
1219
+ # wss_link="wss://sydney.bing.com/sydney/ChatHub"
1220
+ # What other values can this parameter take? It seems to be optional
1221
+ )
1222
+ return response
1223
+ except KeyError:
1224
+ print(
1225
+ f"> KeyError [{Cookie.current_filepath.name} may have exceeded the daily limit]",
1226
+ )
1227
+ Cookie.import_next()
1228
+ retries -= 1
1229
+ finally:
1230
+ await bot.close()
1231
+
1232
+ @property
1233
+ def output(self):
1234
+ """The response from a completed Chatbot request"""
1235
+ return self.response["item"]["messages"][1]["text"]
1236
+
1237
+ @property
1238
+ def sources(self):
1239
+ """The source names and details parsed from a completed Chatbot request"""
1240
+ return self.response["item"]["messages"][1]["sourceAttributions"]
1241
+
1242
+ @property
1243
+ def sources_dict(self):
1244
+ """The source names and details as a dictionary"""
1245
+ sources_dict = {}
1246
+ name = "providerDisplayName"
1247
+ url = "seeMoreUrl"
1248
+ for source in self.sources:
1249
+ if name in source.keys() and url in source.keys():
1250
+ sources_dict[source[name]] = source[url]
1251
+ else:
1252
+ continue
1253
+ return sources_dict
1254
+
1255
+ @property
1256
+ def code(self):
1257
+ """Extract and join any snippets of Python code in the response"""
1258
+ code_blocks = self.output.split("```")[1:-1:2]
1259
+ code_blocks = ["\n".join(x.splitlines()[1:]) for x in code_blocks]
1260
+ return "\n\n".join(code_blocks)
1261
+
1262
+ @property
1263
+ def languages(self):
1264
+ """Extract all programming languages given in code blocks"""
1265
+ code_blocks = self.output.split("```")[1:-1:2]
1266
+ return {x.splitlines()[0] for x in code_blocks}
1267
+
1268
+ @property
1269
+ def suggestions(self):
1270
+ """Follow-on questions suggested by the Chatbot"""
1271
+ return [
1272
+ x["text"]
1273
+ for x in self.response["item"]["messages"][1]["suggestedResponses"]
1274
+ ]
1275
+
1276
+ def __repr__(self):
1277
+ return f"<EdgeGPT.Query: {self.prompt}>"
1278
+
1279
+ def __str__(self):
1280
+ return self.output
1281
+
1282
+
1283
+ class ImageQuery(Query):
1284
+ def __init__(self, prompt, **kwargs):
1285
+ kwargs.update({"content_type": "image"})
1286
+ super().__init__(prompt, **kwargs)
1287
+
1288
+ def __repr__(self):
1289
+ return f"<EdgeGPT.ImageQuery: {self.prompt}>"
1290
+
1291
+
1292
+ if __name__ == "__main__":
1293
+ main()
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: New Bing Chat ENGLISH
3
- emoji: 💻
4
- colorFrom: gray
5
- colorTo: yellow
6
- sdk: streamlit
7
- sdk_version: 1.21.0
8
  app_file: app.py
9
- pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: New-Bing-Chat-ENGLISH
3
+ emoji: 🐨
4
+ colorFrom: red
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 3.23.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: other
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import json
3
+ import asyncio
4
+ import os
5
+ import EdgeGPT
6
+ from EdgeGPT import Chatbot, ConversationStyle
7
+ import re
8
+
9
+ async def get_model_reply(prompt, style, cookies, context=[]):
10
+ context = [prompt]
11
+ cookies = json.loads(cookies)
12
+
13
+ # Rest of the code...
14
+
15
+ # UI code using Streamlit
16
+ def main():
17
+ st.title("New Bing Chat GPT4")
18
+
19
+ st.markdown("""
20
+ - If the response is "1", it means the service is busy. We recommend trying again later.
21
+ - If the response is "0", please refresh the page and try again.
22
+ - If the response is "-1", the account needs to be reactivated using a proxy server.
23
+ - If the response is "-2", the account requires human verification on the Bing chat page.
24
+
25
+ **Note:** The code has been updated to return the desired format when [choices = None] is passed, which means no specific choices mode is selected.
26
+ """)
27
+
28
+ inputs = st.text_input("Enter your question", "Hello")
29
+ style = st.selectbox("Response Style", ["creative", "balanced", "precise"])
30
+
31
+ # Load cookies from JSON file
32
+ with open('./cookies.json', 'r') as f:
33
+ cookies = json.load(f)
34
+
35
+ if st.button("Send Request"):
36
+ state = []
37
+ responses, state = asyncio.run(get_model_reply(inputs, style, json.dumps(cookies), state))
38
+
39
+ if len(responses) > 0:
40
+ for user, bot in responses:
41
+ st.text("User: " + user)
42
+ st.text("Bot: " + bot)
43
+ st.markdown("---")
44
+
45
+ if __name__ == "__main__":
46
+ main()
cookies.json ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ can you help me understand line by line how this bing AI chatbot's cookies work and how they can be used to create python code to use it effectively as a chatbot
2
+
3
+
4
+ \[
5
+ {
6
+ "domain": ".bing.com",
7
+ "expirationDate": 1719057020.716042,
8
+ "hostOnly": false,
9
+ "httpOnly": false,
10
+ "name": "SnrOvr",
11
+ "path": "/",
12
+ "sameSite": "no_restriction",
13
+ "secure": true,
14
+ "session": false,
15
+ "storeId": null,
16
+ "value": "X=rebateson"
17
+ },
18
+ {
19
+ "domain": ".bing.com",
20
+ "expirationDate": 1721994605.964768,
21
+ "hostOnly": false,
22
+ "httpOnly": false,
23
+ "name": "SRCHUSR",
24
+ "path": "/",
25
+ "sameSite": "no_restriction",
26
+ "secure": true,
27
+ "session": false,
28
+ "storeId": null,
29
+ "value": "DOB=20230622&T=1687434589000&POEX=W"
30
+ },
31
+ {
32
+ "domain": "www.bing.com",
33
+ "expirationDate": 1687436423,
34
+ "hostOnly": true,
35
+ "httpOnly": false,
36
+ "name": "ai_session",
37
+ "path": "/",
38
+ "sameSite": "no_restriction",
39
+ "secure": true,
40
+ "session": false,
41
+ "storeId": null,
42
+ "value": "RF1p1mBDe7wTRTseF6Iz+G|1687434592931|1687434623279"
43
+ },
44
+ {
45
+ "domain": ".bing.com",
46
+ "expirationDate": 1687477817.199317,
47
+ "hostOnly": false,
48
+ "httpOnly": true,
49
+ "name": "SUID",
50
+ "path": "/",
51
+ "sameSite": "no_restriction",
52
+ "secure": true,
53
+ "session": false,
54
+ "storeId": null,
55
+ "value": "A"
56
+ },
57
+ {
58
+ "domain": ".bing.com",
59
+ "expirationDate": 1721994620.575677,
60
+ "hostOnly": false,
61
+ "httpOnly": false,
62
+ "name": "SRCHHPGUSR",
63
+ "path": "/",
64
+ "sameSite": "no_restriction",
65
+ "secure": true,
66
+ "session": false,
67
+ "storeId": null,
68
+ "value": "SRCHLANG=en&PV=15.0.0&BRW=S&BRH=S&CW=1067&CH=699&SCW=1067&SCH=699&DPR=1.5&UTC=-300&DM=1&HV=1687434621&WTS=63823031389&PRVCW=1067&PRVCH=699"
69
+ },
70
+ {
71
+ "domain": ".bing.com",
72
+ "expirationDate": 1703245816.640784,
73
+ "hostOnly": false,
74
+ "httpOnly": false,
75
+ "name": "ANON",
76
+ "path": "/",
77
+ "sameSite": "no_restriction",
78
+ "secure": true,
79
+ "session": false,
80
+ "storeId": null,
81
+ "value": "A=B7E892EEC685402345AFB183FFFFFFFF&E=1c7c&W=1"
82
+ },
83
+ {
84
+ "domain": "www.bing.com",
85
+ "expirationDate": 1718970623.060166,
86
+ "hostOnly": true,
87
+ "httpOnly": false,
88
+ "name": "MicrosoftApplicationsTelemetryDeviceId",
89
+ "path": "/",
90
+ "sameSite": "no_restriction",
91
+ "secure": true,
92
+ "session": false,
93
+ "storeId": null,
94
+ "value": "5368eb97-91b2-4a77-a889-5134e8a32352"
95
+ },
96
+ {
97
+ "domain": ".bing.com",
98
+ "hostOnly": false,
99
+ "httpOnly": false,
100
+ "name": "_SS",
101
+ "path": "/",
102
+ "sameSite": "no_restriction",
103
+ "secure": true,
104
+ "session": true,
105
+ "storeId": null,
106
+ "value": "SID=0ACF7BCA173B6ED7179F68F216546F09&R=5130&RB=5130&GB=0&RG=6500&RP=0"
107
+ },
108
+ {
109
+ "domain": ".bing.com",
110
+ "hostOnly": false,
111
+ "httpOnly": false,
112
+ "name": "ipv6",
113
+ "path": "/",
114
+ "sameSite": "no_restriction",
115
+ "secure": true,
116
+ "session": true,
117
+ "storeId": null,
118
+ "value": "hit=1687438193778&t=4"
119
+ },
120
+ {
121
+ "domain": ".bing.com",
122
+ "expirationDate": 1688644216.640939,
123
+ "hostOnly": false,
124
+ "httpOnly": false,
125
+ "name": "_U",
126
+ "path": "/",
127
+ "sameSite": "no_restriction",
128
+ "secure": true,
129
+ "session": false,
130
+ "storeId": null,
131
+ "value": "1sNNlfydW4RjdHkyYqPUG5uPzkvgDSeAmTaeSXs2dXEiqwj1_enafZrbr2G8ca9eSqMPwlNPlTATxSTkkodcii-byULcU7DJ4z45LogCFI9wOwbARwKh_1R-aSJjKHgmgZgbh-66zBybnmH5cNv8flqzxbBKfcPOGhTelwsLXBRToen6oJXni7Re61EEqr1EwSzYpiffyR7iEhK6m849sB1tkaZLHMj4X44kmMrfTuhY"
132
+ },
133
+ {
134
+ "domain": ".bing.com",
135
+ "expirationDate": 1721977968.730789,
136
+ "hostOnly": false,
137
+ "httpOnly": false,
138
+ "name": "SRCHD",
139
+ "path": "/",
140
+ "sameSite": "no_restriction",
141
+ "secure": true,
142
+ "session": false,
143
+ "storeId": null,
144
+ "value": "AF=NOFORM"
145
+ },
146
+ {
147
+ "domain": ".bing.com",
148
+ "expirationDate": 1721994616.640824,
149
+ "hostOnly": false,
150
+ "httpOnly": false,
151
+ "name": "PPLState",
152
+ "path": "/",
153
+ "sameSite": "no_restriction",
154
+ "secure": true,
155
+ "session": false,
156
+ "storeId": null,
157
+ "value": "1"
158
+ },
159
+ {
160
+ "domain": ".bing.com",
161
+ "expirationDate": 1718970621,
162
+ "hostOnly": false,
163
+ "httpOnly": false,
164
+ "name": "amp_e5f096_bing.com",
165
+ "path": "/",
166
+ "sameSite": "lax",
167
+ "secure": false,
168
+ "session": false,
169
+ "storeId": null,
170
+ "value": "0sC_P96Kqk9Ek6aa_qrfma...1h3hf0tsi.1h3hf1s6v.0.0.0"
171
+ },
172
+ {
173
+ "domain": ".bing.com",
174
+ "expirationDate": 1721113969.730779,
175
+ "hostOnly": false,
176
+ "httpOnly": true,
177
+ "name": "_EDGE_V",
178
+ "path": "/",
179
+ "sameSite": null,
180
+ "secure": false,
181
+ "session": false,
182
+ "storeId": null,
183
+ "value": "1"
184
+ },
185
+ {
186
+ "domain": ".bing.com",
187
+ "expirationDate": 1704743416.640806,
188
+ "hostOnly": false,
189
+ "httpOnly": false,
190
+ "name": "NAP",
191
+ "path": "/",
192
+ "sameSite": "no_restriction",
193
+ "secure": true,
194
+ "session": false,
195
+ "storeId": null,
196
+ "value": "V=1.9&E=1c22&C=r7Tz0M2KvloiF0KxUIWf3W1RrAggGI6c3nFHVZKwHZ-rJ6GjWzYDxA&W=1"
197
+ },
198
+ {
199
+ "domain": ".bing.com",
200
+ "expirationDate": 1721994620.965844,
201
+ "hostOnly": false,
202
+ "httpOnly": false,
203
+ "name": "_RwBf",
204
+ "path": "/",
205
+ "sameSite": "no_restriction",
206
+ "secure": true,
207
+ "session": false,
208
+ "storeId": null,
209
+ "value": "ilt=1&ihpd=1&ispd=0&rc=5130&rb=5130&gb=0&rg=6500&pc=0&mtu=0&rbb=0.0&g=0&cid=&clo=0&v=2&l=2023-06-22T07:00:00.0000000Z&lft=0001-01-01T00:00:00.0000000&aof=0&o=16&p=sapphire&c=true&t=6853&s=2023-03-03T18:14:35.9462777+00:00&ts=2023-06-22T11:50:20.9783807+00:00&rwred=0&wls=2&lka=0&lkt=0&TH=&dci=0&r=1&mta=0&e=Lq7CR08AZViOwp0DA2GFsGwJR_yyiHE3vmd6GVsWez-gSWBqaGgwuwOd-KbCVfdJTG0DOYPvU9GfhdtXSBnDSQyOY1H4-eqWU_mbyYVEODY&A=B7E892EEC685402345AFB183FFFFFFFF"
210
+ },
211
+ {
212
+ "domain": ".bing.com",
213
+ "expirationDate": 1721994626.04557,
214
+ "hostOnly": false,
215
+ "httpOnly": false,
216
+ "name": "_UR",
217
+ "path": "/",
218
+ "sameSite": "no_restriction",
219
+ "secure": true,
220
+ "session": false,
221
+ "storeId": null,
222
+ "value": "QS=0&TQS=0"
223
+ },
224
+ {
225
+ "domain": ".bing.com",
226
+ "hostOnly": false,
227
+ "httpOnly": true,
228
+ "name": "_EDGE_S",
229
+ "path": "/",
230
+ "sameSite": null,
231
+ "secure": false,
232
+ "session": true,
233
+ "storeId": null,
234
+ "value": "SID=1A3C463F2C7060292A3755072D1F61DE"
235
+ },
236
+ {
237
+ "domain": ".bing.com",
238
+ "hostOnly": false,
239
+ "httpOnly": true,
240
+ "name": "CSRFCookie",
241
+ "path": "/",
242
+ "sameSite": "no_restriction",
243
+ "secure": true,
244
+ "session": true,
245
+ "storeId": null,
246
+ "value": "1fe5f6f7-0958-4b3f-8afc-1595ba6044a0"
247
+ },
248
+ {
249
+ "domain": "www.bing.com",
250
+ "expirationDate": 1721130625.938491,
251
+ "hostOnly": true,
252
+ "httpOnly": true,
253
+ "name": "MUIDB",
254
+ "path": "/",
255
+ "sameSite": null,
256
+ "secure": false,
257
+ "session": false,
258
+ "storeId": null,
259
+ "value": "3D68C9DDD3BD69290CEFDAE5D2D268C8"
260
+ },
261
+ {
262
+ "domain": ".bing.com",
263
+ "expirationDate": 1721994589.285074,
264
+ "hostOnly": false,
265
+ "httpOnly": true,
266
+ "name": "USRLOC",
267
+ "path": "/",
268
+ "sameSite": "no_restriction",
269
+ "secure": true,
270
+ "session": false,
271
+ "storeId": null,
272
+ "value": "HS=1"
273
+ },
274
+ {
275
+ "domain": ".bing.com",
276
+ "expirationDate": 1721994626.04604,
277
+ "hostOnly": false,
278
+ "httpOnly": false,
279
+ "name": "_HPVN",
280
+ "path": "/",
281
+ "sameSite": "no_restriction",
282
+ "secure": true,
283
+ "session": false,
284
+ "storeId": null,
285
+ "value": "CS=eyJQbiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiUCJ9LCJTYyI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiSCJ9LCJReiI6eyJDbiI6MSwiU3QiOjAsIlFzIjowLCJQcm9kIjoiVCJ9LCJBcCI6dHJ1ZSwiTXV0ZSI6dHJ1ZSwiTGFkIjoiMjAyMy0wNi0yMlQwMDowMDowMFoiLCJJb3RkIjowLCJHd2IiOjAsIkRmdCI6bnVsbCwiTXZzIjowLCJGbHQiOjAsIkltcCI6M30="
286
+ },
287
+ {
288
+ "domain": ".bing.com",
289
+ "expirationDate": 1718970621,
290
+ "hostOnly": false,
291
+ "httpOnly": false,
292
+ "name": "amp_e5f096",
293
+ "path": "/",
294
+ "sameSite": "lax",
295
+ "secure": false,
296
+ "session": false,
297
+ "storeId": null,
298
+ "value": "0sC_P96Kqk9Ek6aa_qrfma...1h3hf0tsi.1h3hf1s5c.0.0.0"
299
+ },
300
+ {
301
+ "domain": ".bing.com",
302
+ "expirationDate": 1721994616.640842,
303
+ "hostOnly": false,
304
+ "httpOnly": true,
305
+ "name": "KievRPSSecAuth",
306
+ "path": "/",
307
+ "sameSite": "no_restriction",
308
+ "secure": true,
309
+ "session": false,
310
+ "storeId": null,
311
+ "value": "FACCBBRaTOJILtFsMkpLVWSG6AN6C/svRwNmAAAEgAAACEQlbg+c+ErCQAQZWRhVAYNGFThpR0iVu5I07ZggVc5dYjPEYkTk0rNO5ooUOn8ayXD6cpcrxEm2JF2jp/Norc8n59KOaQbt54QSDdPxWYxcqX4iGdI/TEX8YWwpKErspCmZITrunIbU1OCwEzgPL0l6CIP+QyJ5b58IDIRJAeJ6hb+ZH66sT6Jhos8x7KcnlCNnlP5kyQuta6/u98xzWHXbSsStGCmTSVfLkAif8mUC8kS1p8/E69mMJbKs9alssXkgQowoXkE9LvKdcrie9tmGG5OzGWSDFEH+bk8ILhcWncYet16bdMy1ChHjxdaEnM3a7HKV0BJ98DOlxKXww/Mw2cBmSlJjZqkH9jL0ZcgImCMrdDUsIDgIsiHO2C8GyDlL3IWZYTA3NhOL49vjE6+EnTlsV2lmBPLepbw+oL7LLRjxSt1xZIFMaDXPx0AEYdmD23x18w3VwR5EoIqBV6XZBynm594n77MYBVnDvbpyT4is4jIo1wzsWs7jApmDL0IJGfehS/E6HmbJGKOgzcP3AteI+zepVdhX+Y8kuJI8ObhaZB9Fy/xuEiqcIiRKXS7NF5E6nFxC/HxASUqrXIp5sDP9qEE37aFAZCDqETwjDpaBQLT4kWP2uaIM4kYbxNKC2A8qcr6AfqTyJvJNT9BphcFZ6hvClM9OFovO5NGGFADwIY3huDLrkhTomZHTbLBVbhRREoqB9eGLbowRJv0NnoaRSLayVxHXMhHCfI0YacCBO/4wGeCA8CH3kSp9fbedydtOG1QqqI2pLeTCgN4gG0bfzM6/JzOHNxl8mo4y48vvdUMvNU0tlaIOIPLEOhYM26YNdO+8VDgv8+SKALK37JNS6vJUSdu/F9rOklSZdouqalCMWMm8Np6PzYN43krmMa4lcrPDmSrseLcK7OJlLFLoQCuDDJKpDoveXGHUpyRbp+IugJcghyomtc9TAvRO9QxJK75xrAsOYKwBrrn4NEFQ8mrxoM/sBfVoMpycmsUZF1zKO/2ps5QVl+ACDYP5BkEWKPNheNKtF37hdgqsxGuw55zq6AtJh3oOgJPoqrF+EsfSGPMWIiiagROcu5Hd6toPvQ2IVsuB8N3bMVnL582aORFaGTtZpi8Y3LhrbF/qBmdQk0NnC6bot40jjMoMZyDVTrd2oXBnSoUOcq5KYdjoXz/5I8wT3wX/9gepi40KBPgia7wg3t91UUtXXXWCJ4+lXphxW9XBtXEW+XnFza9UnQwNifUHIzlF7TMWpOIy2hUEnrTdSQiq7+7ULXegl+u/WPcdWT/+WU2KgVN7qEKel/U9s+5c8oNArTTWDLbv5OoSBgGKioUnKjn7LXYmRMLUd1Nr7+g0reg8u8s3X53h1O7Z6MJ9MyZYHMekpWLZ8SmWA9Pkb2jpGjZjYhBvJthasBgO1GMiME8i3zGJrdJkyD7YV/UhmMjguxoTjWr1rtRFjB+BQRQAtTToVfUNsbaXYzInyoTg/cZTnWQ="
312
+ },
313
+ {
314
+ "domain": ".bing.com",
315
+ "expirationDate": 1721122200.962837,
316
+ "hostOnly": false,
317
+ "httpOnly": false,
318
+ "name": "MUID",
319
+ "path": "/",
320
+ "sameSite": "no_restriction",
321
+ "secure": true,
322
+ "session": false,
323
+ "storeId": null,
324
+ "value": "3D68C9DDD3BD69290CEFDAE5D2D268C8"
325
+ },
326
+ {
327
+ "domain": ".bing.com",
328
+ "expirationDate": 1721977968.730799,
329
+ "hostOnly": false,
330
+ "httpOnly": false,
331
+ "name": "SRCHUID",
332
+ "path": "/",
333
+ "sameSite": "no_restriction",
334
+ "secure": true,
335
+ "session": false,
336
+ "storeId": null,
337
+ "value": "V=2&GUID=D57ED6E662FA4C12ABB4174A433C210E&dmnchg=1"
338
+ },
339
+ {
340
+ "domain": ".bing.com",
341
+ "expirationDate": 1688644217.199239,
342
+ "hostOnly": false,
343
+ "httpOnly": true,
344
+ "name": "WLID",
345
+ "path": "/",
346
+ "sameSite": "no_restriction",
347
+ "secure": true,
348
+ "session": false,
349
+ "storeId": null,
350
+ "value": "VJvwhcbha0XjSWPmoRbUNDvglkf/V3Zi7Zft1ahMWA5Ef1XjikFzakW2fWcpb+ZtTy4BW9dgjX4JhCT7z5M+/L8Tu6LwHP0mG8AGlKZPJkg="
351
+ },
352
+ {
353
+ "domain": ".bing.com",
354
+ "hostOnly": false,
355
+ "httpOnly": false,
356
+ "name": "WLS",
357
+ "path": "/",
358
+ "sameSite": "no_restriction",
359
+ "secure": true,
360
+ "session": true,
361
+ "storeId": null,
362
+ "value": "C=2f1564bfa10412ba&N=grim"
363
+ }
364
+ ]
gitattributes.txt ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ requests
3
+ rich
4
+ websockets
5
+ aiohttp
6
+ BingImageCreator
7
+ certifi
8
+ httpx
9
+ prompt_toolkit
10
+ requests
11
+ rich
12
+
13
+