File size: 1,426 Bytes
612bbc3
 
 
8b6e3d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612bbc3
60aa6e7
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
import gradio as gr
from virtual_human import VirtualHuman

def gradio_interface(message, history, state):
    response = state.gradio_interface(message, history)
    history.append((message, response))
    return "", history, state

def try_again(message, history, state):
    message = ""
    history=[(None, "我通过了你的朋友验证请求,现在我们可以开始聊天了")]
    state.reset()
    return "", history, state


with gr.Blocks() as demo:
    html = gr.HTML("<h1> 任务:获得女生好感,好感度提升可以看女生照片 </h1> \
            <p> 背景信息:你通过朋友的介绍,加入了一个微信群,这是一个讨论文学与艺术的群组。 \
            有一天,你注意到群里有一个特别引人注目的成员,ID为远方的梦,她的头像是一朵粉色的玫瑰花,\
            没有个人资料,只是在群里偶尔发一些有深度的文学感悟。你加了她的微信,她刚刚通过好友验证。 </p>")

    chatbot = gr.Chatbot(value=[(None, "我通过了你的朋友验证请求,现在我们可以开始聊天了")])
    msg = gr.Textbox()
    send = gr.Button("发送")
    clear = gr.Button("再来一局")

    vh = VirtualHuman()
    state = gr.State(vh)

    send.click(gradio_interface, [msg, chatbot, state], [msg, chatbot, state])
    clear.click(try_again, [msg, chatbot, state], [msg, chatbot, state])

demo.launch()