feat(langchain): add CoordinodeGraph.keyword_search()#41
Conversation
Wraps CoordinodeClient.text_search() to expose BM25 full-text search via the LangChain GraphStore adapter. Returns list[dict] with node_id/score/snippet keys, consistent with similarity_search() output. Gracefully returns [] when the injected client has no text_search method (e.g. bare coordinode-embedded LocalClient) to maintain parity with the existing similarity_search() fallback pattern. Closes #22
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds CoordinodeGraph.keyword_search(...) which delegates to the client's text_search(...) with runtime capability checking, forwards parameters (label, query, limit, fuzzy, language), and normalizes results to dicts with keys Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant CoordinodeGraph
participant CoordinodeClient
Caller->>CoordinodeGraph: keyword_search(query, k, label, fuzzy, language)
CoordinodeGraph->>CoordinodeClient: text_search(label=label, query=query, limit=k, fuzzy=fuzzy, language=language)
CoordinodeClient-->>CoordinodeGraph: [TextResult...] / []
CoordinodeGraph->>CoordinodeGraph: normalize -> [{id, score, snippet}, ...] or []
CoordinodeGraph-->>Caller: list of dict results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/test_langchain_graph.py`:
- Around line 52-53: The empty close() methods in the test fakes should include
an explicit no-op rationale to satisfy static analysis; update the close()
implementations in tests/unit/test_langchain_graph.py (the fake client classes'
close methods) to include either a one-line docstring or an inline comment like
"no-op for interface parity with real client" so the intent is documented and
the linter stops flagging the empty bodies.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: dfb6cf6b-7517-4328-9ab2-5ed523118fc4
📒 Files selected for processing (2)
langchain-coordinode/langchain_coordinode/graph.pytests/unit/test_langchain_graph.py
There was a problem hiding this comment.
Pull request overview
Adds a LangChain adapter convenience API for CoordiNode full-text (BM25) search so LangChain users can run keyword queries through CoordinodeGraph, with unit tests validating behavior using mock clients.
Changes:
- Add
CoordinodeGraph.keyword_search()that wraps an injected client’stext_search()when available. - Implement graceful fallback to
[]whentext_searchis not implemented by the injected client. - Add unit tests covering result shaping, parameter forwarding, defaults, and empty/fallback cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
langchain-coordinode/langchain_coordinode/graph.py |
Adds keyword_search() API on CoordinodeGraph wrapping text_search() and shaping results. |
tests/unit/test_langchain_graph.py |
Adds mock-based unit tests for keyword_search() behavior and defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ilarity_search() Both search methods now return dicts with "id" as the node identifier key. Docstring updated to document the cross-method consistency guarantee.
|



Summary
CoordinodeGraph.keyword_search()tolangchain-coordinodeCoordinodeClient.text_search()(BM25 full-text search)list[dict]withnode_id,score,snippetkeysfuzzyandlanguagekwargs forwarded to the underlying client[]when the injected client has notext_searchmethod (e.g. barecoordinode-embeddedLocalClient)Test plan
Closes #22