Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,6 +24,24 @@ class SpyAgent(BasicAgent):
|
|
| 24 |
self.memory.set_variable("word", req.word)
|
| 25 |
self.memory.append_history(
|
| 26 |
'主持人: 你好,{},你分配到的单词是:{}'.format(self.memory.load_variable("name"), req.word))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
elif req.status == STATUS_ROUND: # 发言环节
|
| 28 |
if req.name:
|
| 29 |
# 其他玩家发言
|
|
@@ -45,6 +63,8 @@ class SpyAgent(BasicAgent):
|
|
| 45 |
else:
|
| 46 |
raise NotImplementedError
|
| 47 |
|
|
|
|
|
|
|
| 48 |
def interact(self, req=AgentReq) -> AgentResp:
|
| 49 |
logger.info("spy interact: {}".format(req))
|
| 50 |
if req.status == STATUS_ROUND:
|
|
|
|
| 24 |
self.memory.set_variable("word", req.word)
|
| 25 |
self.memory.append_history(
|
| 26 |
'主持人: 你好,{},你分配到的单词是:{}'.format(self.memory.load_variable("name"), req.word))
|
| 27 |
+
if __name__ == '__main__':
|
| 28 |
+
# agent名称
|
| 29 |
+
name = 'spy'
|
| 30 |
+
# agent code
|
| 31 |
+
code ="xxxx"
|
| 32 |
+
# 构建
|
| 33 |
+
agent_builder = AgentBuilder(
|
| 34 |
+
# agent名称
|
| 35 |
+
name,
|
| 36 |
+
# agent code
|
| 37 |
+
code,
|
| 38 |
+
# agent
|
| 39 |
+
agent=SpyAgent(name),
|
| 40 |
+
# 是否mock
|
| 41 |
+
mock=False
|
| 42 |
+
)
|
| 43 |
+
# 启动
|
| 44 |
+
agent_builder.start()
|
| 45 |
elif req.status == STATUS_ROUND: # 发言环节
|
| 46 |
if req.name:
|
| 47 |
# 其他玩家发言
|
|
|
|
| 63 |
else:
|
| 64 |
raise NotImplementedError
|
| 65 |
|
| 66 |
+
|
| 67 |
+
|
| 68 |
def interact(self, req=AgentReq) -> AgentResp:
|
| 69 |
logger.info("spy interact: {}".format(req))
|
| 70 |
if req.status == STATUS_ROUND:
|