From 55f5b13d8cc76da5c2832beeddcbd99ff1b81360 Mon Sep 17 00:00:00 2001 From: bmy <2583236812@qq.com> Date: Thu, 1 Aug 2024 23:30:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8A=E6=AC=A1?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=B8=AD=E7=9A=84=E9=94=99=E8=AF=AF=E5=92=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- subtask.py | 21 +++++++++++---------- utils.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) 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)