Spaces:
Runtime error
Runtime error
HanYangHanYang
commited on
Upload folder using huggingface_hub
Browse files- app.py +34 -0
- virtual_human.py +1 -1
- web_demo.py +12 -2
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
|
4 |
+
class Human:
|
5 |
+
def __init__(self):
|
6 |
+
self.count = 0
|
7 |
+
print("init")
|
8 |
+
def reset(self):
|
9 |
+
self.count = 0
|
10 |
+
print("reset")
|
11 |
+
|
12 |
+
def echo(self, message, history):
|
13 |
+
self.count += 1
|
14 |
+
return "this round:"+str(self.count)
|
15 |
+
|
16 |
+
h = Human()
|
17 |
+
hs = gr.State(h)
|
18 |
+
|
19 |
+
def output(message, history, s):
|
20 |
+
r = s.echo(message, history)
|
21 |
+
return r
|
22 |
+
|
23 |
+
|
24 |
+
|
25 |
+
demo = gr.ChatInterface(
|
26 |
+
fn=output,
|
27 |
+
additional_inputs=[hs],
|
28 |
+
retry_btn=None,
|
29 |
+
undo_btn=None,
|
30 |
+
submit_btn="发送",
|
31 |
+
#clear_btn="再来一局",
|
32 |
+
clear_btn=gr.ClearButton(hs),
|
33 |
+
title="Echo Bot")
|
34 |
+
demo.launch()
|
virtual_human.py
CHANGED
@@ -195,7 +195,7 @@ class VirtualHuman:
|
|
195 |
return ('girl.jpg',)
|
196 |
elif state == "failed":
|
197 |
gr.Info('挑战失败,女生已删除你的好友')
|
198 |
-
return reply + '
|
199 |
elif state == "ongoing":
|
200 |
return f'【亲密度:{closeness}】:{reply}【{rounds}/{self._conversation_rounds_threshold}】'
|
201 |
elif state == "gameover":
|
|
|
195 |
return ('girl.jpg',)
|
196 |
elif state == "failed":
|
197 |
gr.Info('挑战失败,女生已删除你的好友')
|
198 |
+
return reply + ' 【挑战失败,女生已删除你的好友】'
|
199 |
elif state == "ongoing":
|
200 |
return f'【亲密度:{closeness}】:{reply}【{rounds}/{self._conversation_rounds_threshold}】'
|
201 |
elif state == "gameover":
|
web_demo.py
CHANGED
@@ -3,8 +3,18 @@ from virtual_human import VirtualHuman
|
|
3 |
|
4 |
|
5 |
vh = VirtualHuman()
|
6 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
title="任务:获得女生好感,好感度提升可以看女生照片",
|
8 |
description="背景信息:你通过朋友的介绍,加入了一个微信群,这是一个讨论文学与艺术的群组。\
|
9 |
有一天,你注意到群里有一个特别引人注目的成员,ID为远方的梦,她的头像是一朵粉色的玫瑰花,\
|
10 |
-
没有个人资料,只是在群里偶尔发一些有深度的文学感悟。你加了她的微信,她刚刚通过好友验证.【输入“再来一局” 重新开始】").launch(
|
|
|
3 |
|
4 |
|
5 |
vh = VirtualHuman()
|
6 |
+
state = gr.State(vh)
|
7 |
+
|
8 |
+
def gradio_interface(message, history, state):
|
9 |
+
return state.gradio_interface(message, history)
|
10 |
+
|
11 |
+
gr.ChatInterface(fn=gradio_interface,
|
12 |
+
additional_inputs=[state],
|
13 |
+
retry_btn=None,
|
14 |
+
undo_btn=None,
|
15 |
+
submit_btn="发送",
|
16 |
+
clear_btn=None,
|
17 |
title="任务:获得女生好感,好感度提升可以看女生照片",
|
18 |
description="背景信息:你通过朋友的介绍,加入了一个微信群,这是一个讨论文学与艺术的群组。\
|
19 |
有一天,你注意到群里有一个特别引人注目的成员,ID为远方的梦,她的头像是一朵粉色的玫瑰花,\
|
20 |
+
没有个人资料,只是在群里偶尔发一些有深度的文学感悟。你加了她的微信,她刚刚通过好友验证.【输入“再来一局” 重新开始】").launch()
|