Merged
Conversation
Reviewer's GuideIntroduce a new pytest unit test for SemanticTextMemory that uses a FakeEmbeddingGenerator and VolatileMemoryStore to verify accurate retrieval based on simple synthetic embeddings. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds a unit test to verify semantic memory retrieval functionality. The test validates that the semantic memory system can accurately retrieve stored information based on search queries.
Key Changes
- Creates a new test file for semantic memory retrieval functionality
- Implements a fake embedding generator for testing purposes
- Adds test cases to verify accurate retrieval of stored text information
Comments suppressed due to low confidence (1)
01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py:28
- [nitpick] The test only verifies exact matches but doesn't test semantic similarity or ranking when multiple results are returned. Consider adding test cases for partial matches and verifying the ranking order of search results.
async def test_retrieval_accuracy():
01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py
Show resolved
Hide resolved
01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Hey @Bryan-Roe - I've reviewed your changes - here's some feedback:
- Add numpy to the project’s test or dev dependencies so that
import numpyworks when running tests. - Consider parameterizing the query/text assertions in
test_retrieval_accuracyto reduce repetition and improve readability. - Add a test case with limit > 1 (and multiple expected results) to verify the search result ordering beyond single-item lookups.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add numpy to the project’s test or dev dependencies so that `import numpy` works when running tests.
- Consider parameterizing the query/text assertions in `test_retrieval_accuracy` to reduce repetition and improve readability.
- Add a test case with limit > 1 (and multiple expected results) to verify the search result ordering beyond single-item lookups.
## Individual Comments
### Comment 1
<location> `01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py:2` </location>
<code_context>
+import asyncio
+import numpy as np
+import pytest
+
</code_context>
<issue_to_address>
Test requires numpy but does not skip or handle missing dependency.
Add a check or use pytest.skipif to skip the test if numpy is not installed, ensuring the test suite runs smoothly without numpy.
Suggested implementation:
```python
import asyncio
import pytest
try:
import numpy as np
HAS_NUMPY = True
except ImportError:
HAS_NUMPY = False
from semantic_kernel.memory.volatile_memory_store import VolatileMemoryStore
```
```python
@pytest.mark.skipif(not HAS_NUMPY, reason="numpy is not installed")
class FakeEmbeddingGenerator(EmbeddingGeneratorBase):
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Bryan <74067792+Bryan-Roe@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Bryan <74067792+Bryan-Roe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
python 01-core-implementations/python/tests/unit/memory/test_semantic_memory_retrieval.py(fails: ModuleNotFoundError: No module named 'numpy')https://chatgpt.com/codex/tasks/task_e_6886a79400d083228045f0d4e0ce5e79
Summary by Sourcery
Tests: