File size: 1,264 Bytes
fe317da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from revChatGPT.V1 import Chatbot
import os

email = os.environ.get('email') 
password = os.environ.get('password') 
access_token = None
session_token = None

def configure_chatbot():
 
    config = {}
    config.update({"email": email,
                      "password": password})


    global chatbot
    chatbot = Chatbot(config=config)

login_method = ['Email/Password']

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("""<h1><center>这是一个代理,用于实现免翻</center></h1> """)
    gr.Markdown("#### 作者不便署名,直接使用就行")
    gr.Markdown("#### 用爱发电甚难,不要随便乱谈")

    configure_chatbot()

    gr.Markdown("""<h2>Start Chatting ...</h2>""")
    chatbot1 = gr.Chatbot()
    message = gr.Textbox(placeholder="Chat here")
    state = gr.State()
    submit = gr.Button("SEND")
    submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot1, state])

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