File size: 1,744 Bytes
fe317da
 
 
118f709
 
fe317da
 
 
fcd34b2
fe317da
fcd34b2
 
fe317da
 
 
 
b92bb00
fe317da
 
 
 
 
 
 
 
 
 
 
 
 
 
118f709
 
 
 
fcd34b2
 
 
 
 
 
 
118f709
fcd34b2
 
 
8c4364d
fcd34b2
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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> """)

if not email or password:
    gr.Markdown("""<h2>请使用openAI账户登录</h2>""")
    with gr.Row():
         email = gr.Textbox(placeholder="请输入openAI的邮箱地址")
    with gr.Row():
         password = gr.Textbox(placeholder="请输入openAI的登录密码")
    with gr.Row():
                    login = gr.Button("输完箱密点此登录")
                    login.click(configure_chatbot, inputs=[email, password])
elif email and password:
           configure_chatbot(email,password)
              
gr.Markdown("""<h2>开始聊吧 ...</h2>""")
chatbot1 = gr.Chatbot()
message = gr.Textbox(placeholder="Chat here")
state = gr.State()
submit = gr.Button("输入完成一定要点击这里发送")
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot1, state])

demo.launch(debug = True, share=False)