该项目已存档。由于个人情况,我没有时间来维持此存储库。
边缘GPT
!!!!可能不再需要!!! 在某些地区,微软使每个人都可以使用聊天功能,因此您可以跳过此步骤。您可以通过尝试在不登录的情况下启动聊天来使用浏览器(用用户代理设置以反射边缘)检查一下。 还发现它可能取决于您的IP地址。例如,如果您尝试从已知属于数据中心范围的IP中访问聊天功能(VSERVERS,根服务器,VPN,Common Proxies,…),则可能需要登录,同时可以从您的家庭IP地址访问该功能。 如果收到以下错误,则可以尝试提供cookie并查看它是否有效,然后: 例外:身份验证失败。您尚未被接受到Beta。 EdgeGPT -h EdgeGPT – A demo of reverse engineering the Bing GPT chatbot !help for help Type !exit to exit usage: EdgeGPT .py [-h] [–enter-once] [–search-result] [–no-stream] [–rich] [–proxy PROXY] [–wss-link WSS_LINK] options: (中国/美国/英国/挪威对地方的支持得到了增强) 例如,使用异步来获得最佳体验,例如: EdgeGPT import Chatbot, ConversationStyle async def main(): if __name__ == \”__main__\”: 创建一个简单的Bing Chat AI查询(默认使用“精确”对话样式),仅查看主要文本输出,而不是整个API响应: remeber以特定格式存储您的cookie:bing_cookies _*。json。 EdgeGPT.EdgeUtils import Query, Cookie q = Query(\”What are you? Give your answer as Python code\”) 存储cookie文件的默认目录是Home/bing_cookies,但您可以通过以下方式更改它: 或更改要使用的对话样式或cookie文件: 快速提取文本输出,代码段,源/参考列表或使用以下属性从响应中提出的后续问题: 获取您指定的原始提示和对话样式: 自导入查询以来进行的访问以前的查询: 最后,cookie类支持多个cookie文件,因此,如果您使用命名约定的bing_cookies _*。json创建其他cookie文件,您的查询将自动尝试使用下一个文件(如果您超过了每日的请求的配额)(当前设置为200)。 这是您可以访问的主要属性: 这假设您当前的工作目录中有一个文件cookies.json 您可以添加任何额外的标志如下 根据简单的提示生成图像,然后下载到当前的工作目录: EdgeGPT.EdgeUtils import ImageQuery q=ImageQuery(\”Meerkats at a garden party in Devon\”)\”> 更改本会话中所有未来图像的下载目录: EdgeGPT.ImageGen import ImageGen async def async_image_gen(args) -> None: if __name__ == \”__main__\”: if args.U is None: if not args.asyncio: 由于所有贡献的人,该项目的存在。
设置
安装软件包
python3 -m pip install EdgeGPT --upgrade
要求
验证
收集饼干
在代码中使用cookie:
cookies = json . loads ( open ( \"./path/to/cookies.json\" , encoding = \"utf-8\" ). read ()) # might omit cookies option
bot = await Chatbot . create ( cookies = cookies )
如何使用聊天机器人
从指令行跑
Repo: github.com/acheong08/ EdgeGPT
By: Antonio Cheong
[–style {creative,balanced,precise}] [–prompt PROMPT] [–cookie-file COOKIE_FILE]
[–history-file HISTORY_FILE] [–locale LOCALE]
-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)\”> $ python3 -m EdgeGPT . EdgeGPT -h
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
usage: EdgeGPT .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)
在Python跑
1。聊天机器人类和异步
bot = await Chatbot.create() # Passing cookies is \”optional\”, as explained above
response = await bot.ask(prompt=\”Hello world\”, conversation_style=ConversationStyle.creative, simplify_response=True)
print(json.dumps(response, indent=2)) # Returns
\”\”\”
{
\”text\”: str,
\”author\”: str,
\”sources\”: list[dict],
\”sources_text\”: str,
\”suggestions\”: list[str],
\”messages_left\”: int
}
\”\”\”
await bot.close()
asyncio.run(main())\”> import asyncio , json
from EdgeGPT . EdgeGPT import Chatbot , ConversationStyle
async def main ():
bot = await Chatbot . create () # Passing cookies is \"optional\", as explained above
response = await bot . ask ( prompt = \"Hello world\" , conversation_style = ConversationStyle . creative , simplify_response = True )
print ( json . dumps ( response , indent = 2 )) # Returns
\"\"\"
{
\"text\": str,
\"author\": str,
\"sources\": list[dict],
\"sources_text\": str,
\"suggestions\": list[str],
\"messages_left\": int
}
\"\"\"
await bot . close ()
if __name__ == \"__main__\" :
asyncio . run ( main ())
2)查询和饼干助手课程
print(q)\”> from EdgeGPT . EdgeUtils import Query , Cookie
q = Query ( \"What are you? Give your answer as Python code\" )
print ( q )
Cookie . dir_path = Path ( r\"...\" )
q = Query (
\"What are you? Give your answer as Python code\" ,
style = \"creative\" , # or: \'balanced\', \'precise\'
cookie_file = \"./bing_cookies_alternative.json\"
)
# Use `help(Query)` to see other supported parameters.
q . output # Also: print(q)
q . sources
q . sources_dict
q . suggestions
q . code
q . code_blocks
q . code_block_formatsgiven )
q . prompt
q . ignore_cookies
q . style
q . simplify_response
q . locale
repr ( q )
Query . index # A list of Query objects; updated dynamically
Query . image_dir_path
Cookie . current_file_index
Cookie . current_file_path
Cookie . current_data
Cookie . dir_path
Cookie . search_pattern
Cookie . files
Cookie . image_token
Cookie . import_next
Cookie . rotate_cookies
Cookie . ignore_files
Cookie . supplied_files
Cookie . request_count
与Docker一起运行
docker run --rm -it -v $( pwd ) /cookies.json:/cookies.json:ro -e COOKIE_FILE= \' /cookies.json \' ghcr.io/acheong08/ EdgeGPT
docker run --rm -it -v $( pwd ) /cookies.json:/cookies.json:ro -e COOKIE_FILE= \' /cookies.json \' ghcr.io/acheong08/ EdgeGPT --rich --style creative
如何使用图像生成器
从指令行跑
$ python3 -m ImageGen.ImageGen -h
usage: ImageGen.py [-h] [-U U] [--cookie-file COOKIE_FILE] --prompt PROMPT [--output-dir OUTPUT_DIR] [--quiet] [--asyncio]
optional arguments:
-h, --help show this help message and exit
-U U Auth cookie from browser
--cookie-file COOKIE_FILE
File containing auth cookie
--prompt PROMPT Prompt to generate images for
--output-dir OUTPUT_DIR
Output directory
--quiet Disable pipeline messages
--asyncio Run ImageGen using asyncio
在Python跑
1)ImageQuery助手课程
from EdgeGPT . EdgeUtils import ImageQuery
q = ImageQuery ( \"Meerkats at a garden party in Devon\" )
Query.image_dirpath = Path(\"./to_another_folder\")
2)图像Gen类和异步用于更颗粒的控制
import argparse
import json
async with ImageGenAsync(args.U, args.quiet) as image_generator:
images = await image_generator.get_images(args.prompt)
await image_generator.save_images(images, output_dir=args.output_dir)
parser = argparse.ArgumentParser()
parser.add_argument(\”-U\”, help=\”Auth cookie from browser\”, type=str)
parser.add_argument(\”–cookie-file\”, help=\”File containing auth cookie\”, type=str)
parser.add_argument(
\”–prompt\”,
help=\”Prompt to generate images for\”,
type=str,
required=True,
)
parser.add_argument(
\”–output-dir\”,
help=\”Output directory\”,
type=str,
default=\”./output\”,
)
parser.add_argument(
\”–quiet\”, help=\”Disable pipeline messages\”, action=\”store_true\”
)
parser.add_argument(
\”–asyncio\”, help=\”Run ImageGen using asyncio\”, action=\”store_true\”
)
args = parser.parse_args()
# Load auth cookie
with open(args.cookie_file, encoding=\”utf-8\”) as file:
cookie_json = json.load(file)
for cookie in cookie_json:
if cookie.get(\”name\”) == \”_U\”:
args.U = cookie.get(\”value\”)
break
raise Exception(\”Could not find auth cookie\”)
# Create image generator
image_generator = ImageGen(args.U, args.quiet)
image_generator.save_images(
image_generator.get_images(args.prompt),
output_dir=args.output_dir,
)
else:
asyncio.run(async_image_gen(args))
\”> from EdgeGPT . ImageGen import ImageGen
import argparse
import json
async def async_image_gen ( args ) -> None :
async with ImageGenAsync ( args . U , args . quiet ) as image_generator :
images = await image_generator . get_images ( args . prompt )
await image_generator . save_images ( images , output_dir = args . output_dir )
if __name__ == \"__main__\" :
parser = argparse . ArgumentParser ()
parser . add_argument ( \"-U\" , help = \"Auth cookie from browser\" , type = str )
parser . add_argument ( \"--cookie-file\" , help = \"File containing auth cookie\" , type = str )
parser . add_argument (
\"--prompt\" ,
help = \"Prompt to generate images for\" ,
type = str ,
required = True ,
)
parser . add_argument (
\"--output-dir\" ,
help = \"Output directory\" ,
type = str ,
default = \"./output\" ,
)
parser . add_argument (
\"--quiet\" , help = \"Disable pipeline messages\" , action = \"store_true\"
)
parser . add_argument (
\"--asyncio\" , help = \"Run ImageGen using asyncio\" , action = \"store_true\"
)
args = parser . parse_args ()
# Load auth cookie
with open ( args . cookie_file , encoding = \"utf-8\" ) as file :
cookie_json = json . load ( file )
for cookie in cookie_json :
if cookie . get ( \"name\" ) == \"_U\" :
args . U = cookie . get ( \"value\" )
break
if args . U is None :
raise Exception ( \"Could not find auth cookie\" )
if not args . asyncio :
# Create image generator
image_generator = ImageGen ( args . U , args . quiet )
image_generator . save_images (
image_generator . get_images ( args . prompt ),
output_dir = args . output_dir ,
)
else :
asyncio . run ( async_image_gen ( args ))
星历史
贡献者
