From d731fd85cd6ee311a79c88a732316f7c555aa502 Mon Sep 17 00:00:00 2001 From: stellahsr Date: Wed, 11 Oct 2023 17:05:01 +0800 Subject: [PATCH] update player_action.py, change to _check --- metagpt/actions/minecraft/player_action.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/metagpt/actions/minecraft/player_action.py b/metagpt/actions/minecraft/player_action.py index 4a90b84da..58f121878 100644 --- a/metagpt/actions/minecraft/player_action.py +++ b/metagpt/actions/minecraft/player_action.py @@ -7,28 +7,25 @@ import json from metagpt.actions import Action from langchain.vectorstores import Chroma from langchain.embeddings.openai import OpenAIEmbeddings -from metagpt.document_store import FaissStore from metagpt.const import CKPT_DIR from metagpt.config import CONFIG -from metagpt.logs import logger -from metagpt.actions.minecraft.control_primitives import load_skills_code class PlayerActions(Action): def __init__(self, name="", context=None, llm=None): super().__init__(name, context, llm) - self.skills = {} # for skills.json - self.qa_cache = {} + self.skills_check = {} # for skills.json + self.qa_cache_check = {} self.check_init = True if ( CONFIG.resume ): # TODO: now for assert only, no update, cuz program using in step() with open(f"{CKPT_DIR}/skill/skills.json", "r") as f: - self.skills = json.load(f) + self.skills_check = json.load(f) with open(f"{CKPT_DIR}/curriculum/qa_cache.json", "r") as f: - self.qa_cache = json.load(f) + self.qa_cache_check = json.load(f) self.retrieval_top_k = 5 @@ -47,19 +44,19 @@ class PlayerActions(Action): # FIXME if self.check_init: # Check if Skill Manager's vectordb right using - assert self.vectordb._collection.count() >= len(self.skills), ( + assert self.vectordb._collection.count() >= len(self.skills_check), ( f"Skill Manager's vectordb is not synced with skills.json.\n" - f"There are {self.vectordb._collection.count()} skills in vectordb but {len(self.skills)} skills in skills.json.\n" + f"There are {self.vectordb._collection.count()} skills in vectordb but {len(self.skills_check)} skills in skills.json.\n" f"Did you set resume=False when initializing the manager?\n" f"You may need to manually delete the vectordb directory for running from scratch." ) # Check if Skill Manager's vectordb right using assert self.qa_cache_questions_vectordb._collection.count() >= len( - self.qa_cache + self.qa_cache_check ), ( f"Curriculum Agent's qa cache question vectordb is not synced with qa_cache.json.\n" f"There are {self.qa_cache_questions_vectordb._collection.count()} questions in vectordb " - f"but {len(self.qa_cache)} questions in qa_cache.json.\n" + f"but {len(self.qa_cache_check)} questions in qa_cache.json.\n" f"Did you set resume=False when initializing the agent?\n" f"You may need to manually delete the qa cache question vectordb directory for running from scratch.\n" )