dotmet commited on
Commit
8c40b3a
1 Parent(s): 937e8a8

Upload 4 files

Browse files
Files changed (4) hide show
  1. LICENSE +28 -0
  2. README.md +2 -13
  3. app.py +74 -0
  4. requirements.txt +2 -0
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 CHANGED
@@ -1,13 +1,2 @@
1
- ---
2
- title: Chatgpt Webui
3
- emoji: 💩
4
- colorFrom: indigo
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 3.18.0
8
- app_file: app.py
9
- pinned: false
10
- license: bsd-3-clause
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ # chatgpt_webui
2
+ Build an WebUI of ChatGPT with multiple authentication method using Gradio and revChatGPT
 
 
 
 
 
 
 
 
 
 
 
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from revChatGPT.V1 import Chatbot
4
+
5
+ #You can setup login information here, or login in from UI
6
+ email = None
7
+ password = None
8
+ access_token = None
9
+ session_token = None
10
+
11
+ def configure_chatbot(method, info):
12
+
13
+ if method=="Email/Password":
14
+ email, password = info.split()
15
+ elif method=="access_token":
16
+ access_token = info
17
+ elif method=="session_token":
18
+ session_token = info
19
+
20
+ config = {}
21
+ if email and password:
22
+ config.update({"email": email,
23
+ "password": password})
24
+ elif access_token:
25
+ config.update({"access_token": access_token})
26
+ elif session_token:
27
+ config.update({"session_token": session_token})
28
+
29
+ global chatbot
30
+ chatbot = Chatbot(config=config)
31
+
32
+ login_method = ['Email/Password',
33
+ 'Access token',
34
+ 'Session token',
35
+ ]
36
+
37
+ def ask_bot(prompt):
38
+ message = ""
39
+ for data in chatbot.ask(prompt):
40
+ message = data["message"]
41
+ return message
42
+
43
+ def chatgpt_clone(inputs, history):
44
+ history = history or []
45
+ # s = list(sum(history, ()))
46
+ # s.append(inputs)
47
+ # inp = ' '.join(s)
48
+ # print(inp)
49
+ output = ask_bot(inputs)
50
+ history.append((inputs, output))
51
+ return history, history
52
+
53
+ with gr.Blocks() as demo:
54
+ gr.Markdown("""<h1><center>ChatGPT BOT build by revChatGPT & Gradio</center></h1>
55
+ """)
56
+
57
+ if not ((email and password) or access_token or session_token):
58
+ gr.Markdown("""<h2>Login to OpenAI<h2>""")
59
+ with gr.Row():
60
+ with gr.Group():
61
+ method = gr.Dropdown(label="Login Method", choices=login_method)
62
+ info = gr.Textbox(placeholder="email password/access_token/session_token", label="Login Information")
63
+ with gr.Row():
64
+ login = gr.Button("Login")
65
+ login.click(configure_chatbot, inputs=[method, info])
66
+
67
+ gr.Markdown("""<h2>Start Chatting ...<h2>""")
68
+ chatbot1 = gr.Chatbot()
69
+ message = gr.Textbox(placeholder="Chat here")
70
+ state = gr.State()
71
+ submit = gr.Button("SEND")
72
+ submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot1, state])
73
+
74
+ demo.launch(debug = True, share=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ revChatGPT
2
+ gradio