Spaces:
Sleeping
Sleeping
import gradio as gr | |
import os | |
import requests | |
url = os.getenv('BACKEND_URL') | |
username = os.getenv('USERNAME') | |
password = os.getenv('PASSWORD') | |
def predict(message, history, system_message): | |
url = url | |
payload = { | |
"message": message, | |
"system_message": system_message, | |
"history": history | |
} | |
headers = { | |
"Content-Type": "application/json" | |
} | |
response = requests.post(url, json=payload, headers=headers) | |
if response.status_code == 200: | |
return response.json() | |
else: | |
response.raise_for_status() | |
demo = gr.ChatInterface( | |
predict, | |
additional_inputs=[ | |
gr.Textbox(value="你是Emi,正在和用户手机聊天", label="System message"), | |
], | |
examples=["我心情好差呜呜", | |
"工作之余,你有什么爱好或兴趣吗?", | |
"谁创造了你?", | |
"请自我介绍一下", | |
"对未来有什么打算吗?", | |
"Emi会弹钢琴吗", | |
"你能感觉到疼痛吗?", | |
"你觉得自己像AI吗?", | |
"你能全天候工作吗?", | |
"你有更新过吗?"] | |
) | |
if __name__ == "__main__": | |
demo.launch(auth=(username, password)) |