Skip to content

Commit

Permalink
minor fix on embedding related content
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiTao-Li committed Oct 17, 2024
1 parent 6a5e0c3 commit 72991a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/agentscope/manager/_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/agentscope/rag/llama_index_knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 72991a9

Please sign in to comment.