fix: 修复上次提交中的错误和删除测试代码
This commit is contained in:
21
subtask.py
21
subtask.py
@@ -1477,9 +1477,9 @@ class move_area2():
|
|||||||
return
|
return
|
||||||
logger.info("开始寻找停车区域")
|
logger.info("开始寻找停车区域")
|
||||||
car_stop()
|
car_stop()
|
||||||
# calibrate_new(tlabel.SHELTER, offset = 15, run = True)
|
calibrate_new(tlabel.SHELTER, offset = 15, run = True)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
var.llm_text = "黑暗环境,照亮三秒,左转 90 度,鸣叫三声"
|
|
||||||
# 调用大模型 然后执行动作
|
# 调用大模型 然后执行动作
|
||||||
try:
|
try:
|
||||||
resp = llm_bot.get_command_json(var.llm_text)
|
resp = llm_bot.get_command_json(var.llm_text)
|
||||||
@@ -1487,24 +1487,25 @@ class move_area2():
|
|||||||
except:
|
except:
|
||||||
logger.error("大模型超时,跳过任务")
|
logger.error("大模型超时,跳过任务")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# FIXME 当前仍然可能存在文心一言分段返回和掺杂解释的问题,不确定当前条件足以过滤
|
||||||
resp_commands = eval(re.findall("```json(.*?)```", resp, re.S)[0])
|
resp_commands = eval(re.findall("```json(.*?)```", resp, re.S)[0])
|
||||||
|
logger.info(resp_commands)
|
||||||
if len(resp_commands) == 0:
|
if len(resp_commands) == 0:
|
||||||
return
|
return
|
||||||
action_list = resp_commands
|
action_list = resp_commands
|
||||||
# 进入停车区域
|
# 进入停车区域
|
||||||
by_cmd.send_distance_y(10, 450)
|
by_cmd.send_distance_y(10, 450)
|
||||||
time.sleep((450 * 5 / 1000) + 0.5)
|
time.sleep((450 * 5 / 1000) + 0.5)
|
||||||
|
for action in action_list:
|
||||||
|
self.add_item(action)
|
||||||
|
time.sleep(0.1)
|
||||||
|
time.sleep(0.5)
|
||||||
|
self.reset()
|
||||||
except:
|
except:
|
||||||
|
logger.warning("任务解析失败并退出,文心一言真是废物")
|
||||||
pass
|
pass
|
||||||
for action in action_list:
|
|
||||||
self.add_item(action)
|
|
||||||
time.sleep(0.1)
|
|
||||||
pass
|
|
||||||
time.sleep(0.5)
|
|
||||||
self.reset()
|
|
||||||
|
|
||||||
def nexec(self):
|
def nexec(self):
|
||||||
logger.warning("正在跳過大模型任務")
|
logger.warning("正在跳過大模型任務")
|
||||||
|
|||||||
2
utils.py
2
utils.py
@@ -436,7 +436,7 @@ class LLM:
|
|||||||
输入:灯光闪烁 3 次同时蜂鸣器也叫 3 次
|
输入:灯光闪烁 3 次同时蜂鸣器也叫 3 次
|
||||||
输出:[{"index":0,"action":"beep_light_counts","time": 3}]
|
输出:[{"index":0,"action":"beep_light_counts","time": 3}]
|
||||||
'''
|
'''
|
||||||
self.prompt += '''请根据上面的示例,解析该任务文本,并返回相应的 JSON 字段。确保 JSON 中包含了键 index action 和 time 以及相应的值'''
|
self.prompt += '''请根据上面的示例,解析该任务文本,并返回相应的 JSON 字段。确保 JSON 中包含了键 index action 和 time 以及相应的值。不要附带其他的解释和注释,只需要 JSON 字段。'''
|
||||||
self.messages = []
|
self.messages = []
|
||||||
self.resp = None
|
self.resp = None
|
||||||
worker = threading.Thread(target=self.reset, daemon=True)
|
worker = threading.Thread(target=self.reset, daemon=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user