Spaces:
Runtime error
Runtime error
Commit
•
ce0bc70
0
Parent(s):
Duplicate from dotmet/chatgpt_webui
Browse filesCo-authored-by: HuggingMat <dotmet@users.noreply.huggingface.co>
- .gitattributes +34 -0
- LICENSE +28 -0
- README.md +16 -0
- app.py +106 -0
- requirements.txt +2 -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
|
LICENSE
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
BSD 3-Clause License
|
2 |
+
|
3 |
+
Copyright (c) 2023, Mension
|
4 |
+
|
5 |
+
Redistribution and use in source and binary forms, with or without
|
6 |
+
modification, are permitted provided that the following conditions are met:
|
7 |
+
|
8 |
+
1. Redistributions of source code must retain the above copyright notice, this
|
9 |
+
list of conditions and the following disclaimer.
|
10 |
+
|
11 |
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
12 |
+
this list of conditions and the following disclaimer in the documentation
|
13 |
+
and/or other materials provided with the distribution.
|
14 |
+
|
15 |
+
3. Neither the name of the copyright holder nor the names of its
|
16 |
+
contributors may be used to endorse or promote products derived from
|
17 |
+
this software without specific prior written permission.
|
18 |
+
|
19 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
20 |
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21 |
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
22 |
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
23 |
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
24 |
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
25 |
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
26 |
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
27 |
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: bsd-2-clause
|
3 |
+
title: ChatGPT WebUI
|
4 |
+
sdk: gradio
|
5 |
+
emoji: 👀
|
6 |
+
colorFrom: yellow
|
7 |
+
colorTo: red
|
8 |
+
app_file: app.py
|
9 |
+
duplicated_from: dotmet/chatgpt_webui
|
10 |
+
---
|
11 |
+
# chatgpt_webui
|
12 |
+
Build an WebUI of ChatGPT with multiple authentication method using Gradio and revChatGPT
|
13 |
+
|
14 |
+
clone this space to run for your own account
|
15 |
+
|
16 |
+
### This project will not SAVE/DISPLAY/SHARE the ACCOUNT INFO of any user!!
|
app.py
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from revChatGPT.V1 import Chatbot
|
3 |
+
|
4 |
+
#You can setup login information here, or login in from UI
|
5 |
+
|
6 |
+
# If you want to use Email/Password to login, put your account information here
|
7 |
+
email = None
|
8 |
+
password = None
|
9 |
+
|
10 |
+
# If you have an access token, replace the None with your token
|
11 |
+
access_token = None
|
12 |
+
|
13 |
+
# If you have a session token, put your session token here
|
14 |
+
session_token = None
|
15 |
+
|
16 |
+
def configure_chatbot(method, info):
|
17 |
+
|
18 |
+
if method=="Email/Password":
|
19 |
+
email, password = info.split()
|
20 |
+
elif method=="Access token":
|
21 |
+
access_token = info
|
22 |
+
elif method=="Session token":
|
23 |
+
session_token = info
|
24 |
+
|
25 |
+
config = {}
|
26 |
+
if email and password:
|
27 |
+
config.update({"email": email,
|
28 |
+
"password": password})
|
29 |
+
elif access_token:
|
30 |
+
config.update({"access_token": access_token})
|
31 |
+
elif session_token:
|
32 |
+
config.update({"session_token": session_token})
|
33 |
+
|
34 |
+
global chatbot
|
35 |
+
chatbot = Chatbot(config=config)
|
36 |
+
|
37 |
+
login_method = ['Email/Password',
|
38 |
+
'Access token',
|
39 |
+
'Session token',
|
40 |
+
]
|
41 |
+
|
42 |
+
def ask_bot(prompt):
|
43 |
+
message = ""
|
44 |
+
for data in chatbot.ask(prompt):
|
45 |
+
message = data["message"]
|
46 |
+
return parse_text(message)
|
47 |
+
|
48 |
+
def parse_text(text):
|
49 |
+
lines = text.split("\n")
|
50 |
+
for i,line in enumerate(lines):
|
51 |
+
if "```" in line:
|
52 |
+
items = line.split('`')
|
53 |
+
if items[-1]:
|
54 |
+
lines[i] = f'<pre><code class="{items[-1]}">'
|
55 |
+
else:
|
56 |
+
lines[i] = f'</code></pre>'
|
57 |
+
else:
|
58 |
+
if i>0:
|
59 |
+
lines[i] = '<br/>'+line.replace(" ", " ")
|
60 |
+
return "".join(lines)
|
61 |
+
|
62 |
+
def chatgpt_clone(inputs, history):
|
63 |
+
history = history or []
|
64 |
+
output = ask_bot(inputs)
|
65 |
+
history.append((inputs, output))
|
66 |
+
return history, history
|
67 |
+
|
68 |
+
with gr.Blocks() as demo:
|
69 |
+
gr.Markdown("""<h1><center>ChatGPT BOT build by revChatGPT & Gradio</center></h1>
|
70 |
+
""")
|
71 |
+
gr.Markdown(
|
72 |
+
"#### Author: [dotmet](https://github.com/dotmet) Github link:[ChatGPTWEB](https://github.com/dotmet/chatgpt_webui)")
|
73 |
+
gr.Markdown(
|
74 |
+
"I have used my own OpenAI account for this demo,you can skip Login and try chat.")
|
75 |
+
gr.Markdown(
|
76 |
+
"Duplicate this space and run for your own account: [demo](https://huggingface.co/spaces/dotmet/chatgpt_webui?duplicate=true).")
|
77 |
+
|
78 |
+
if not ((email and password) or access_token or session_token):
|
79 |
+
gr.Markdown("""<h2>Login to OpenAI</h2>""")
|
80 |
+
with gr.Row():
|
81 |
+
with gr.Group():
|
82 |
+
method = gr.Dropdown(label="Login Method", choices=login_method)
|
83 |
+
info = gr.Textbox(placeholder="email password/access_token/session_token", label="Login Information (select login method first)")
|
84 |
+
with gr.Row():
|
85 |
+
login = gr.Button("Login")
|
86 |
+
login.click(configure_chatbot, inputs=[method, info])
|
87 |
+
else:
|
88 |
+
if email and password:
|
89 |
+
method = "Email/Password"
|
90 |
+
info = email + " " + password
|
91 |
+
elif access_token:
|
92 |
+
method = "Access token"
|
93 |
+
info = access_token
|
94 |
+
elif session_token:
|
95 |
+
method = "Session token"
|
96 |
+
info = session_token
|
97 |
+
configure_chatbot(method, info)
|
98 |
+
|
99 |
+
gr.Markdown("""<h2>Start Chatting ...</h2>""")
|
100 |
+
chatbot1 = gr.Chatbot()
|
101 |
+
message = gr.Textbox(placeholder="Chat here")
|
102 |
+
state = gr.State()
|
103 |
+
submit = gr.Button("SEND")
|
104 |
+
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot1, state])
|
105 |
+
|
106 |
+
demo.launch(debug = True, share=False)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
revChatGPT
|
2 |
+
gradio
|