From 72991a9c347b8d1bf1ed83f7099f9adf698ef506 Mon Sep 17 00:00:00 2001 From: ZiTao-Li Date: Wed, 16 Oct 2024 21:07:33 -0700 Subject: [PATCH] minor fix on embedding related content --- src/agentscope/manager/_file.py | 5 ++--- src/agentscope/rag/llama_index_knowledge.py | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/agentscope/manager/_file.py b/src/agentscope/manager/_file.py index 8fe93b171..8d2d67d12 100644 --- a/src/agentscope/manager/_file.py +++ b/src/agentscope/manager/_file.py @@ -34,13 +34,12 @@ def _get_text_embedding_record_hash( if isinstance(embedding_model, dict): # Format the dict to avoid duplicate keys embedding_model = json.dumps(embedding_model, sort_keys=True) - elif isinstance(embedding_model, str): - embedding_model_hash = _hash_string(embedding_model, hash_method) - else: + elif not isinstance(embedding_model, str): raise RuntimeError( f"The embedding model must be a string or a dict, got " f"{type(embedding_model)}.", ) + embedding_model_hash = _hash_string(embedding_model, hash_method) # Calculate the embedding id by hashing the hash codes of the # original data and the embedding model diff --git a/src/agentscope/rag/llama_index_knowledge.py b/src/agentscope/rag/llama_index_knowledge.py index 142f71068..b886825ff 100644 --- a/src/agentscope/rag/llama_index_knowledge.py +++ b/src/agentscope/rag/llama_index_knowledge.py @@ -203,8 +203,9 @@ def __init__( ) if persist_root is None: - persist_root = FileManager.get_instance().run_dir or "./" + persist_root = FileManager.get_instance().cache_dir or "./" self.persist_dir = os.path.join(persist_root, knowledge_id) + logger.info(f"** persist_dir: {self.persist_dir}") self.emb_model = emb_model self.overwrite_index = overwrite_index self.showprogress = showprogress