Mecca Lorentz commited on
Commit
c88d046
0 Parent(s):

Duplicate from hOTZR/new-Bing-with_your_cookies

Browse files

Co-authored-by: Lorentz <hOTZR@users.noreply.huggingface.co>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. README.md +14 -0
  3. app.py +58 -0
  4. cookies.json +1 -0
  5. requirements.txt +5 -0
.gitattributes 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
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: New-Bing-with Your Cookies
3
+ emoji: 🐨
4
+ colorFrom: green
5
+ colorTo: pink
6
+ sdk: gradio
7
+ sdk_version: 3.23.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ duplicated_from: hOTZR/new-Bing-with_your_cookies
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import json
3
+ import asyncio
4
+ import os
5
+ from EdgeGPT import Chatbot, ConversationStyle
6
+
7
+ #read cookie from local file
8
+ # with open('./cookies.json', 'r') as f:
9
+ # cookies = json.load(f)
10
+
11
+ async def get_model_reply(prompt,style,cookies,context=[]):
12
+ # combines the new question with a previous context
13
+ context += [prompt]
14
+ cookies = json.loads(cookies)
15
+ # given the most recent context (4096 characters)
16
+ # continue the text up to 2048 tokens ~ 8192 charaters
17
+ bot = Chatbot(cookies=cookies)
18
+ raw_data = await bot.ask(prompt, conversation_style=style)
19
+ await bot.close()
20
+ #print(raw_data)
21
+ response = raw_data["item"]["messages"][1]["text"]
22
+ context += [response]
23
+
24
+ # list of (user, bot) responses. We will use this format later
25
+ responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
26
+
27
+ return responses, context
28
+ # query = 'Which is the largest country by area in the world?'
29
+ # style="precise"
30
+ # responses, context =asyncio.run(get_model_reply(query,style,context=[]))
31
+ #
32
+ # print(' ' + responses[-1][0])
33
+ # print(' ' + responses[-1][1])
34
+ with gr.Blocks() as dialog_app:
35
+ with gr.Tab("Cookies"):
36
+ cookies = gr.Textbox(lines=2, label="输入bing.com中的cookies")
37
+ with gr.Tab("New Bing Chat"):
38
+ gr.Markdown("# A Simple Web to use New Bing Without Magic")
39
+ chatbot = gr.Chatbot()
40
+ state = gr.State([])
41
+ markdown = gr.Markdown(label="Output")
42
+
43
+ with gr.Row():
44
+ inputs = gr.Textbox(
45
+ label="输入问题",
46
+ placeholder="Enter text and press enter"
47
+ )
48
+ style = gr.Dropdown(label="回答倾向", choices=["creative", "balanced", "precise"], multiselect=False,
49
+ value="balanced", type="value")
50
+
51
+ inputs.submit(get_model_reply, [inputs, style, cookies, state], [chatbot, state])
52
+ send = gr.Button("Send")
53
+ send.click(get_model_reply, [inputs, style, cookies, state], [chatbot, state])
54
+
55
+ # launches the app in a new local port
56
+ dialog_app.launch()
57
+ # 为网站设置密码防止滥用
58
+ # dialog_app.launch(auth=("admin", "pass1234"))
cookies.json ADDED
@@ -0,0 +1 @@
 
 
1
+ paste your cookies of bing.com here
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ requests
3
+ rich
4
+ websockets
5
+ EdgeGPT