Spaces:
Sleeping
Sleeping
File size: 1,664 Bytes
445a1bc 9752490 6cbb12f 9de19e4 9752490 9de19e4 9752490 9de19e4 9752490 445a1bc 9de19e4 445a1bc 9752490 |
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 |
import gradio as gr
import os
import requests
url = os.getenv('BACKEND_URL')
username = os.getenv('USERNAME')
password = os.getenv('PASSWORD')
system_prompt_text = "你是Emi,正在和用户手机聊天"
def predict(message, history):
global system_prompt_text
url = url
payload = {
"message": message,
"system_message": system_prompt_text,
"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()
def update_system_prompt(new_content):
global system_prompt_text
system_prompt_text = new_content
with gr.Blocks() as demo:
gr.ChatInterface(
predict,
examples=["我心情好差呜呜",
"工作之余,你有什么爱好或兴趣吗?",
"谁创造了你?",
"请自我介绍一下",
"对未来有什么打算吗?",
"Emi会弹钢琴吗",
"你能感觉到疼痛吗?",
"你觉得自己像AI吗?",
"你能全天候工作吗?",
"你有更新过吗?"]
)
system_prompt = gr.Textbox(value=system_prompt_text, info="System Message:", placeholder="你是Emi",
interactive=True, lines=30)
system_prompt.change(
fn=update_system_prompt, inputs=system_prompt)
if __name__ == "__main__":
demo.launch(auth=(username, password)) |