docs(client): fix packaged search result examples - #1346
Conversation
|
@haosenwang1018 thank you for the pull request submission. Please sign your commits, resolve the unit test failures, and review the CoPilot feedback. You only need to resolve the relevant items. Thanks. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Aligns the published Python client documentation/examples with the current search-result object API and updated filter field conventions, while extending the client APIs to accept raw filter strings.
Changes:
- Update README + docs + examples to use attribute-style search results (
results.episodic_memory,results.semantic_memory) andmetadata.*filter keys. - Add optional raw
filterstring support toMemory.search()/Memory.list()and thread it through LangGraph tools. - Expand/adjust unit + integration tests to cover raw filter passthrough and updated filter key formats.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/client/src/memmachine_client/memory.py | Adds `filter: str |
| packages/client/src/memmachine_client/langgraph.py | Adds episode_type passthrough + normalizes string episode types; threads raw filter into memory search. |
| packages/client/client_tests/test_memory.py | Adds tests for raw filter strings; updates filter key expectations to metadata.*. |
| packages/client/client_tests/test_langgraph.py | Adds coverage for raw filter passthrough + episode type normalization; updates tool call expectations. |
| packages/client/client_tests/test_integration_complete.py | Updates integration test to use metadata.time in filter_dict. |
| packages/client/README.md | Fixes packaged README examples for search results and filter keys. |
| examples/memmachine_client_demo.py | Updates example to use object-style search results and fields. |
| docs/api_reference/python/client.mdx | Updates docs example to use object-style search results and fields. |
Comments suppressed due to low confidence (1)
packages/client/src/memmachine_client/memory.py:459
- Adding
filteras a positional parameter inlist()changes the positional-argument order (it sits betweenfilter_dictandset_metadata). Any existing callers passingset_metadataortimeoutpositionally will now be interpreted as providingfilter, which is a breaking change. Makefilterkeyword-only (e.g., introduce a*before it) or append it after existing positional params to preserve backward compatibility; also consider matchingsearch()(wherefilteris keyword-only) for API consistency.
def list(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| page_size: int = 100, | ||
| page_num: int = 0, | ||
| filter_dict: dict[str, str] | None = None, | ||
| filter: str | None = None, | ||
| set_metadata: dict[str, JsonValue] | None = None, | ||
| timeout: int | None = None, | ||
| ) -> ListResult: |
There was a problem hiding this comment.
Adding filter as a positional parameter in list() changes the positional-argument order (it sits between filter_dict and set_metadata). Any existing callers passing set_metadata or timeout positionally will now be interpreted as providing filter, which is a breaking change. Make filter keyword-only (e.g., introduce a * before it) or append it after existing positional params to preserve backward compatibility; also consider matching search() (where filter is keyword-only) for API consistency.
| filter_dict: dict[str, str] | None = None, | ||
| timeout: int | None = None, | ||
| *, | ||
| filter: str | None = None, | ||
| set_metadata: dict[str, JsonValue] | None = None, | ||
| agent_mode: bool = False, | ||
| ) -> SearchResult: |
There was a problem hiding this comment.
The PR description states this is a docs-only alignment for README examples, but this diff also introduces a new public API surface (filter parameter on Memory.search() and Memory.list()), plus related LangGraph and test changes. Please update the PR description (and the declared change type, if needed) to reflect the actual scope, or split the API changes into a separate PR to keep the docs-only intent accurate.
|
Hi @haosenwang1018! For this PR (and all your other PRs) to merge, we need you to sign your commits. Also, please review the feedback CoPilot has generated and respond accordingly. Conflicts are especially important to respond to. Kind Regards, |
…ion (#1403) * feat(client+langgraph): raw filter strings and EpisodeType normalization Add three small features to the Python client and its LangGraph wrapper so callers can pass structured filter expressions and either-enum-or-string episode types directly. 1. `Memory.search(filter=...)` and `Memory.list(filter=...)` Accept an optional raw filter string alongside `filter_dict`. When both are provided, the two are combined with `AND`. The raw filter is passed through to the v2 `SearchMemoriesSpec.filter` / `ListMemoriesSpec.filter` fields unchanged. 2. `MemMachineTools.search_memory(filter=...)` Pipes the same raw filter through the LangGraph search-memory tool. 3. `MemMachineTools.add_memory(episode_type=...)` Accept either an `EpisodeType` enum or its string value (e.g. `"message"`), normalizing strings via `EpisodeType(...)` before delegating to `Memory.add`. The factory tool's return-type annotation was widened to match. The `filter` parameter shadows the Python builtin, which is the same trade-off `memmachine_common.api.SearchMemoriesSpec` already made for its `filter:` field — keeping the parameter name aligned with the API field. `# noqa: A002` is applied at the three call sites with a comment pointing at the API spec. This commit consolidates the substantive work from haosenwang1018's 9-commit stack (#1341 → #1349) into a single rebased+linted commit against current `main`. The original stack's prefix-style doc and test changes have been omitted because they have already landed on `main` via #1352 and #1311. The original commits authored by haosenwang1018: - 921b55f feat(client): support raw filter strings - e0849bb feat(langgraph): support raw filter strings - 53b489e fix(langgraph): normalize episode type strings Closes #1341, #1342, #1343, #1344, #1345, #1346, #1347, #1348, #1349 Co-authored-by: Steve Scargall <steve.scargall@gmail.com> Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com> * docs(langgraph): document filter and episode type support --------- Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com> Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com> Co-authored-by: Shu Wang <33640803+malatewang@users.noreply.github.com>
|
Closed by #1403 |
Purpose of the change
Keep the published Python client README aligned with the corrected search-result object API examples.
Description
Follow-up to #973 and #1305
This updates
packages/client/README.mdto:results.get('episodic_memory', [])withresults.episodic_memory or []profile_memoryprint example withsemantic_memoryfilter_dict={"category": "work"}tofilter_dict={"metadata.category": "work"}The
egg-infocopy is generated packaging output and remains intentionally untouched here; regenerating package metadata will pick up the README source change.Type of change
How Has This Been Tested?
Manual verification:
packages/client/README.mdnow usesresults.episodic_memory or []results.semantic_memory or []filter_dict={"metadata.category": "work"}Checklist
Maintainer Checklist