update player_action.py, change to _check

This commit is contained in:
stellahsr 2023-10-11 17:05:01 +08:00
parent dd99839836
commit d731fd85cd

View file

@ -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"
)