From 64828f10479b8d244591d2a9f45079fbff2829dd Mon Sep 17 00:00:00 2001 From: hajdul88 <52442977+hajdul88@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:30:29 +0200 Subject: [PATCH] chore: sets default to 1 for last_k in search (#1412) ## Description Adds default value for last_k in search to avoid unwanted failure when users don't provide the needed parameter. ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [x] Code refactoring - [ ] Performance improvement - [ ] Other (please specify): ## Changes Made Add default value to last_k. ## Testing Manual + tests are already present for the funtionality ## Screenshots/Videos (if applicable) None ## Pre-submission Checklist - [x] **I have tested my changes thoroughly before submitting this PR** - [x] **This PR contains minimal changes necessary to address the issue/feature** - [x] My code follows the project's coding standards and style guidelines - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added necessary documentation (if applicable) - [x] All new and existing tests pass - [x] I have searched existing PRs to ensure this change hasn't been submitted already - [x] I have linked any relevant issues in the description - [x] My commits have clear and descriptive messages ## Related Issues None ## Additional Notes None ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --- cognee/api/v1/search/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cognee/api/v1/search/search.py b/cognee/api/v1/search/search.py index 0e7cb6d85..dcebce012 100644 --- a/cognee/api/v1/search/search.py +++ b/cognee/api/v1/search/search.py @@ -22,7 +22,7 @@ async def search( node_type: Optional[Type] = NodeSet, node_name: Optional[List[str]] = None, save_interaction: bool = False, - last_k: Optional[int] = None, + last_k: Optional[int] = 1, only_context: bool = False, use_combined_context: bool = False, ) -> Union[List[SearchResult], CombinedSearchResult]: