Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hotfix] minor fix on embedding related bugs #463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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