Skip to content

Commit

Permalink
fix embedding mode (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
yewentao256 authored Jul 31, 2024
1 parent 569fa3c commit aa9c115
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lazyllm/tools/rag/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def has_embedding(self) -> bool:
return self.embedding and self.embedding[0] != -1 # placeholder

def do_embedding(self, embed: Callable) -> None:
self.embedding = embed(self.text)
self.embedding = embed(self.get_content(MetadataMode.EMBED))
self.is_saved = False

def get_content(self, metadata_mode: MetadataMode = MetadataMode.NONE) -> str:
Expand Down
7 changes: 7 additions & 0 deletions tests/basic_tests/test_doc_node.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from unittest.mock import MagicMock
from lazyllm.tools.rag.store import DocNode, MetadataMode


Expand All @@ -15,6 +16,12 @@ def setup_method(self):
self.node.excluded_embed_metadata_keys = ["author"]
self.node.excluded_llm_metadata_keys = ["date"]

def test_do_embedding(self):
"""Test that do_embedding passes the correct content to the embed function."""
mock_embed = MagicMock(return_value=[0.4, 0.5, 0.6])
self.node.do_embedding(mock_embed)
mock_embed.assert_called_once_with(self.node.get_content(MetadataMode.EMBED))

def test_node_creation(self):
"""Test the creation of a DocNode."""
assert self.node.text == self.text
Expand Down

0 comments on commit aa9c115

Please sign in to comment.