The reverse engineering the chat feature of the new version of Bing
If you have any problem watch bottom Q&A first.
python3 -m pip install re_edge_gpt --upgrade
!!! POSSIBLY NOT REQUIRED ANYMORE !!!
In some regions, Microsoft has made the chat feature available to everyone, so you might be able to skip this step. You can check this with a browser (with user-agent set to reflect Edge), by trying to start a chat without logging in.
It was also found that it might depend on your IP address. For example, if you try to access the chat features from an IP that is known to belong to a datacenter range (vServers, root servers, VPN, common proxies, ...), you might be required to log in while being able to access the features just fine from your home IP address.
If you receive the following error, you can try providing a cookie and see if it works then:
Exception: Authentication failed. You have not been accepted into the beta.
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51
). You can do this easily with an extension like "User-Agent Switcher and Manager" for Chrome and Firefox.bing_cookies.json
.
bing_cookies.json
, so that they could be recognized by internal cookie processing mechanisms</details> <summary>import json from re_edge_gpt import Chatbot async def create_bot(): cookies = json.loads(open("./path/to/bing_cookies.json", encoding="utf-8").read()) bot = await Chatbot.create(cookies=cookies) return bot
$ python3 -m re_edge_gpt -h
ReEdgeGPT - A demo of reverse engineering the Bing GPT chatbot
!help for help
Type !exit to exit
usage: __main__.py [-h] [--enter-once] [--search-result] [--no-stream] [--rich] [--proxy PROXY] [--wss-link WSS_LINK]
[--style {creative,balanced,precise}] [--prompt PROMPT] [--cookie-file COOKIE_FILE]
[--history-file HISTORY_FILE] [--locale LOCALE]
options:
-h, --help show this help message and exit
--enter-once
--search-result
--no-stream
--rich
--proxy PROXY Proxy URL (e.g. socks5://127.0.0.1:1080)
--wss-link WSS_LINK WSS URL(e.g. wss://sydney.bing.com/sydney/ChatHub)
--style {creative,balanced,precise}
--prompt PROMPT prompt to start with
--cookie-file COOKIE_FILE
path to cookie file
--history-file HISTORY_FILE
path to history file
--locale LOCALE your locale (e.g. en-US, zh-CN, en-IE, en-GB)
(China/US/UK/Norway has enhanced support for locale)
Chatbot
class and asyncio
for more granular controlUse Async for the best experience, for example:
</details> <summary>import asyncio import json from pathlib import Path from re_edge_gpt import Chatbot from re_edge_gpt import ConversationStyle # If you are using jupyter pls install this package # from nest_asyncio import apply async def test_ask() -> None: bot = None try: cookies = json.loads(open( str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read()) bot = await Chatbot.create(cookies=cookies) response = await bot.ask( prompt="How to boil the egg", conversation_style=ConversationStyle.balanced, simplify_response=True ) # If you are using non ascii char you need set ensure_ascii=False print(json.dumps(response, indent=2, ensure_ascii=False)) # Raw response # print(response) assert response except Exception as error: raise error finally: if bot is not None: await bot.close() if __name__ == "__main__": # If you are using jupyter pls use nest_asyncio apply() # apply() try: loop = asyncio.get_running_loop() except RuntimeError: loop = asyncio.get_event_loop() loop.run_until_complete(test_ask())
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51
). You can do this easily with an extension like "User-Agent Switcher and Manager" for Chrome and Firefox.copilot_cookies.json
.
copilot_cookies.json
, so that they could be recognized by internal cookie processing mechanismsimport asyncio import json from pathlib import Path from re_edge_gpt import Chatbot from re_edge_gpt import ConversationStyle # If you are using jupyter pls install this package # from nest_asyncio import apply async def test_ask() -> None: bot = None try: mode = "Copilot" if mode == "Bing": cookies: list[dict] = json.loads(open( str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read()) else: cookies: list[dict] = json.loads(open( str(Path(str(Path.cwd()) + "/copilot_cookies.json")), encoding="utf-8").read()) # Notice when mode != "Bing" (Bing is default) will set mode is copilot bot = await Chatbot.create(cookies=cookies, mode=mode) response = await bot.ask( prompt="Is your name Copilot", conversation_style=ConversationStyle.balanced, simplify_response=True ) # If you are using non ascii char you need set ensure_ascii=False print(json.dumps(response, indent=2, ensure_ascii=False)) # Raw response # print(response) assert response except Exception as error: raise error finally: if bot is not None: await bot.close() if __name__ == "__main__": # If you are using jupyter pls use nest_asyncio apply() # apply() try: loop = asyncio.get_running_loop() except RuntimeError: loop = asyncio.get_event_loop() loop.run_until_complete(test_ask())
Chromium based browsers (Edge, Opera, Vivaldi, Brave)
- Go to https://bing.com/
- F12 to open console
- In the JavaScript console, type cookieStore.get("_U").then(result => console.log(result.value)) and press enter
- Copy the output. This is used in --U or auth_cookie.
Firefox
- Go to https://bing.com/.
- F12 to open developer tools
- navigate to the storage tab
- expand the cookies tab
- click on the https://bing.com cookie
- copy the value from the _U
</details> <summary>import os import shutil from pathlib import Path from re_edge_gpt import ImageGen, ImageGenAsync # create a temporary output directory for testing purposes test_output_dir = "test_output" # download a test image test_image_url = "https://picsum.photos/200" auth_cooker = open("bing_cookies.txt", "r+").read() sync_gen = ImageGen(auth_cookie=auth_cooker) async_gen = ImageGenAsync(auth_cookie=auth_cooker) def test_save_images_sync(): sync_gen.save_images([test_image_url], test_output_dir) sync_gen.save_images([test_image_url], test_output_dir, file_name="test_image") # check if the image was downloaded and saved correctly assert os.path.exists(os.path.join(test_output_dir, "test_image_0.jpeg")) assert os.path.exists(os.path.join(test_output_dir, "0.jpeg")) # Generate image list sync def test_generate_image_sync(): image_list = sync_gen.get_images("tree") print(image_list) if __name__ == "__main__": # Make dir to save image Path("test_output").mkdir(exist_ok=True) # Save image test_save_images_sync() # Generate image sync test_generate_image_sync() # Remove dir shutil.rmtree(test_output_dir)
https://github.com/Integration-Automation/ReEdgeGPT/issues/119
Example:
import asyncio import json from pathlib import Path from random import choice from string import ascii_uppercase from re_edge_gpt import Chatbot from re_edge_gpt import ConversationStyle # If you are using jupyter pls install this package # from nest_asyncio import apply async def test_ask() -> None: bot = None try: cookies: list[dict] = json.loads(open( str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read()) bot = await Chatbot.create(cookies=cookies, mode="Bing", plugin_ids=["c310c353-b9f0-4d76-ab0d-1dd5e979cf68"]) prompt = """Rome (Italian and Latin: Roma, Italian: [ˈroːma] ⓘ) is the capital city of Italy. It is also the capital of the Lazio region, the centre of the Metropolitan City of Rome Capital, and a special comune (municipality) named Comune di Roma Capitale. With 2,860,009 residents in 1,285 km2 (496.1 sq mi),[2] Rome is the country's most populated comune and the third most populous city in the European Union by population within city limits. The Metropolitan City of Rome, with a population of 4,355,725 residents, is the most populous metropolitan city in Italy.[3] Its metropolitan area is the third-most populous within Italy.[5] Rome is located in the central-western portion of the Italian Peninsula, within Lazio (Latium), along the shores of the Tiber. Vatican City (the smallest country in the world)[6] is an independent country inside the city boundaries of Rome, the only existing example of a country within a city. Rome is often referred to as the City of Seven Hills due to its geographic location, and also as the "Eternal City". Rome is generally considered to be the cradle of Western civilization and Western Christian culture, and the centre of the Catholic Church.[7][8][9] Rome's history spans 28 centuries. While Roman mythology dates the founding of Rome at around 753 BC, the site has been inhabited for much longer, making it a major human settlement for almost three millennia and one of the oldest continuously occupied cities in Europe.[10] The city's early population originated from a mix of Latins, Etruscans, and Sabines. Eventually, the city successively became the capital of the Roman Kingdom, the Roman Republic and the Roman Empire, and is regarded by many as the first-ever Imperial city and metropolis.[11] It was first called The Eternal City (Latin: Urbs Aeterna; Italian: La Città Eterna) by the Roman poet Tibullus in the 1st century BC, and the expression was also taken up by Ovid, Virgil, and Livy.[12][13] Rome is also called "Caput Mundi" (Capital of the World). After the fall of the Empire in the west, which marked the beginning of the Middle Ages, Rome slowly fell under the political control of the Papacy, and in the 8th century, it became the capital of the Papal States, which lasted until 1870. Beginning with the Renaissance, almost all popes since Nicholas V (1447–1455) pursued a coherent architectural and urban programme over four hundred years, aimed at making the city the artistic and cultural centre of the world.[14] In this way, Rome first became one of the major centres of the Renaissance[15] and then became the birthplace of both the Baroque style and Neoclassicism. Famous artists, painters, sculptors, and architects made Rome the centre of their activity, creating masterpieces throughout the city. In 1871, Rome became the capital of the Kingdom of Italy, which, in 1946, became the Italian Republic. In 2019, Rome was the 14th most visited city in the world, with 8.6 million tourists, the third most visited city in the European Union, and the most popular tourist destination in Italy.[16] Its historic centre is listed by UNESCO as a World Heritage Site.[17] The host city for the 1960 Summer Olympics, Rome is also the seat of several specialised agencies of the United Nations, such as the Food and Agriculture Organization (FAO), the World Food Programme (WFP) and the International Fund for Agricultural Development (IFAD). The city also hosts the Secretariat of the Parliamentary Assembly of the Union for the Mediterranean[18] (UfM) as well as the headquarters of many multinational companies, such as Eni, Enel, TIM, Leonardo, and banks such as BNL. Numerous companies are based within Rome's EUR business district, such as the luxury fashion house Fendi located in the Palazzo della Civiltà Italiana. The presence of renowned international brands in the city has made Rome an important centre of fashion and design, and the Cinecittà Studios have been the set of many Academy Award–winning movies.[19] Name and symbol Etymology According to the Ancient Romans' founding myth,[20] the name Roma came from the city's founder and first king, Romulus.[1] However, it is possible that the name Romulus was actually derived from Rome itself.[21] As early as the 4th century, there have been alternative theories proposed on the origin of the name Roma. Several hypotheses have been advanced focusing on its linguistic roots which however remain uncertain:[22] From Rumon or Rumen, archaic name of the Tiber,
AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。
一站式AI创作平台
提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作
AI办公助手,复杂任务高效处理
AI办公助手,复杂任务高效处理。办公效率低?扣子空间AI助手支持播客生成、PPT制作、网页开发及报告写作,覆盖科研、商业、舆情等领域的专家Agent 7x24小时响应,生活工作无缝切换,提升50%效率!
AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。
AI小说写作助手,一站式润色、改写、扩写
蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。
全能AI智能助手,随时解答生活与工作的多样问题
问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。
实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。
一键生成PPT和Word,让学习生活更轻松
讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。
深度推理能力全新升级,全面对标OpenAI o1
科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。
一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型
Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。
最新AI工具、AI资讯
独家AI资源、AI项目落地
微信扫一扫关注公众号