diff --git a/subtask.py b/subtask.py index 9da6c60..820270d 100644 --- a/subtask.py +++ b/subtask.py @@ -1477,9 +1477,9 @@ class move_area2(): return logger.info("开始寻找停车区域") car_stop() - # calibrate_new(tlabel.SHELTER, offset = 15, run = True) + calibrate_new(tlabel.SHELTER, offset = 15, run = True) time.sleep(0.5) - var.llm_text = "黑暗环境,照亮三秒,左转 90 度,鸣叫三声" + # 调用大模型 然后执行动作 try: resp = llm_bot.get_command_json(var.llm_text) @@ -1487,24 +1487,25 @@ class move_area2(): except: logger.error("大模型超时,跳过任务") return - - + try: + # FIXME 当前仍然可能存在文心一言分段返回和掺杂解释的问题,不确定当前条件足以过滤 resp_commands = eval(re.findall("```json(.*?)```", resp, re.S)[0]) + logger.info(resp_commands) if len(resp_commands) == 0: return action_list = resp_commands # 进入停车区域 by_cmd.send_distance_y(10, 450) 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: + logger.warning("任务解析失败并退出,文心一言真是废物") pass - for action in action_list: - self.add_item(action) - time.sleep(0.1) - pass - time.sleep(0.5) - self.reset() def nexec(self): logger.warning("正在跳過大模型任務") diff --git a/utils.py b/utils.py index 54ebea7..4a6ae68 100644 --- a/utils.py +++ b/utils.py @@ -436,7 +436,7 @@ class LLM: 输入:灯光闪烁 3 次同时蜂鸣器也叫 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.resp = None worker = threading.Thread(target=self.reset, daemon=True)