2023-10-10 20:47:32 +08:00
|
|
|
|
import py_trees as ptree
|
2023-11-08 15:28:01 +08:00
|
|
|
|
from robowaiter.behavior_lib._base.Act import Act
|
2023-10-25 22:12:15 +08:00
|
|
|
|
from robowaiter.llm_client.ask_llm import ask_llm
|
2023-11-09 16:07:02 +08:00
|
|
|
|
|
2023-11-09 08:47:57 +08:00
|
|
|
|
fixed_answers = {
|
|
|
|
|
"测试VLM:做一杯咖啡":
|
|
|
|
|
'''
|
|
|
|
|
测试VLM:做一杯咖啡
|
|
|
|
|
---
|
|
|
|
|
{"At(Coffee,Bar)"}
|
|
|
|
|
'''
|
|
|
|
|
,
|
|
|
|
|
"测试VLN:前往桌子":
|
|
|
|
|
'''
|
|
|
|
|
测试VLN:前往桌子
|
|
|
|
|
---
|
|
|
|
|
{"At(Robot,Table)"}
|
|
|
|
|
'''
|
|
|
|
|
,
|
|
|
|
|
}
|
2023-11-08 15:28:01 +08:00
|
|
|
|
class DealChat(Act):
|
2023-11-08 10:03:40 +08:00
|
|
|
|
def __init__(self):
|
|
|
|
|
super().__init__()
|
2023-10-17 16:28:36 +08:00
|
|
|
|
|
2023-10-25 22:12:15 +08:00
|
|
|
|
def _update(self) -> ptree.common.Status:
|
2023-10-25 10:34:24 +08:00
|
|
|
|
# if self.scene.status?
|
2023-10-25 22:12:15 +08:00
|
|
|
|
chat = self.scene.state['chat_list'].pop()
|
2023-11-08 15:28:01 +08:00
|
|
|
|
|
|
|
|
|
# 判断是否是测试
|
2023-11-09 08:47:57 +08:00
|
|
|
|
if chat in fixed_answers.keys():
|
|
|
|
|
sentence,goal = fixed_answers[chat].split("---")
|
|
|
|
|
sentence = sentence.strip()
|
|
|
|
|
goal = goal.strip()
|
|
|
|
|
print(f'机器人回答:{sentence}')
|
|
|
|
|
goal = eval(goal)
|
|
|
|
|
print(f'goal:{goal}')
|
2023-11-08 15:28:01 +08:00
|
|
|
|
|
2023-11-09 08:47:57 +08:00
|
|
|
|
self.create_sub_task(goal)
|
|
|
|
|
else:
|
|
|
|
|
answer = ask_llm(chat)
|
|
|
|
|
print(f"机器人回答:{answer}")
|
2023-11-09 17:06:34 +08:00
|
|
|
|
if self.scene.show_bubble:
|
|
|
|
|
self.scene.chat_bubble(f"机器人回答:{answer}")
|
2023-10-25 22:12:15 +08:00
|
|
|
|
|
|
|
|
|
return ptree.common.Status.RUNNING
|
2023-11-08 17:37:49 +08:00
|
|
|
|
|
|
|
|
|
|
2023-11-09 08:47:57 +08:00
|
|
|
|
def create_sub_task(self,goal):
|
|
|
|
|
self.scene.robot.expand_sub_task_tree(goal)
|