|
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) |