feat: Update parameters in search API route to match search function parameters order (#528)
<!-- .github/pull_request_template.md --> ## Description <!-- Provide a clear description of the changes in this PR --> **Updated handling of SearchType through the chain:** Router receives JSON with searchType Enum, example: "searchType": "CHUNKS" FastAPI converts to SearchType enum via SearchPayloadDTO search_v2.py expects SearchType enum search.py takes SearchType enum and extracts value log_query.py takes string value Query model stores string in database **get_search_router.py** Matched the exact field name from JSON payload searchType instead of search_type in the SearchPayloadDTO class. Changed cognee_search() params to use payload.query and payload.searchType **search.py** Changed query_type to SearchType log_query to accept query_type.value parameter instead of str(query_type) ## 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 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated the search functionality to improve consistency and reliability. - Enhanced validation by switching to stricter search type checks, ensuring only valid search types are processed. - Maintained robust error handling for uninterrupted search operations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Co-authored-by: Boris <boris@topoteretes.com>
This commit is contained in:
parent
20cbcbf52b
commit
a602094598
2 changed files with 5 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ from cognee.modules.users.methods import get_authenticated_user
|
|||
|
||||
|
||||
class SearchPayloadDTO(InDTO):
|
||||
search_type: SearchType
|
||||
search_type: SearchType
|
||||
query: str
|
||||
|
||||
|
||||
|
|
@ -38,7 +38,8 @@ def get_search_router() -> APIRouter:
|
|||
from cognee.api.v1.search import search as cognee_search
|
||||
|
||||
try:
|
||||
results = await cognee_search(payload.query, payload.search_type, user)
|
||||
|
||||
results = await cognee_search(query_text = payload.query, query_type = payload.search_type, user=user)
|
||||
|
||||
return results
|
||||
except Exception as error:
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ from ..operations import log_query, log_result
|
|||
|
||||
async def search(
|
||||
query_text: str,
|
||||
query_type: str,
|
||||
query_type: SearchType,
|
||||
datasets: list[str],
|
||||
user: User,
|
||||
):
|
||||
query = await log_query(query_text, str(query_type), user.id)
|
||||
query = await log_query(query_text, query_type.value, user.id)
|
||||
|
||||
own_document_ids = await get_document_ids_for_user(user.id, datasets)
|
||||
search_results = await specific_search(query_type, query_text, user)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue