zss2341's picture
Update app.py
233a051
raw
history blame
1.92 kB
import gradio as gr
from revChatGPT.V1 import Chatbot
email = None
password = None
access_token = None
session_token = None
def configure_chatbot(email, password):
config = {}
config.update({"email": email,
"password": password})
global chatbot
chatbot = Chatbot(config=config)
def ask_bot(prompt):
message = ""
for data in chatbot.ask(prompt):
message = data["message"]
return message
def chatgpt_clone(inputs, history):
history = history or []
output = ask_bot(inputs)
history.append((inputs, output))
return history, history
with gr.Blocks() as demo:
gr.Markdown("""<h2><center>一个代理,免验免翻</center></h2> """)
gr.Markdown("""<h2><center>兴趣所致,用爱发电</center></h2> """)
gr.Markdown("""<h2><center>自用即可,能力有限</center></h2> """)
gr.Markdown("""<h2><center>网址常变,来去随缘</center></h2> """)
if not password:
gr.Markdown("""<h2>请使用openAI账户登录</h2>""")
with gr.Row():
with gr.Column():
email = gr.Textbox(label="输入openAI的邮箱地址")
password = gr.Textbox(label="输入openAI的登录密码", type = password)
login = gr.Button("输完箱密点此登录,点了即可,没做反馈")
login.click(configure_chatbot, inputs=[email, password])
elif password:
configure_chatbot(email, password)
gr.Markdown("""<h2>点完登录就开始聊吧 ...</h2>""")
chatbot1 = gr.Chatbot()
message = gr.Textbox(placeholder="点这个框输入聊天内容", label="人类:", max_lines=10)
state = gr.State()
submit = gr.Button("输入后点击这里发送")
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot1, state])
demo.launch(debug = True, share=False)