clarkchan's picture
Update app.py
a169d7c
raw
history blame
1.36 kB
import gradio as gr
import requests
#from transformers import AutoTokenizer
#tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
def chat(input):
global conversation_history
url = 'http://dark.21cnai.com:5000/api/chat'
data = { "message": input }
headers = {"Content-Type": "Application/json","Authorization":"Bearer kdfjwoieskdflasdnf"}
response = f"您说:{input_text}\n"
conversation_history += response
response = requests.post(url, json=data, headers=headers)
conversation_history += ”chatGPT:"+response.text
return conversation_history
css = '''
.input_text, .output_text {
font-family: Arial, sans-serif;
font-size: 16px;
}
.input_text:focus {
border: 2px solid #2C7BE5;
outline: none;
}
.output_text {
background-color: #F8F9FA;
border: 1px solid #CED4DA;
color: #495057;
}
.input_button {
background-color: #2C7BE5;
color: white;
font-weight: bold;
border: none;
}
'''
iface = gr.Interface(fn=chat, inputs=gr.inputs.Textbox(lines=3, placeholder="在此输入您的问题..."), outputs=gr.outputs.Textbox(),title="ChatGPT 对话",description="请输入您的问题,然后按回车键或单击提交。",css=css)
iface.launch(server_name="0.0.0.0")