feat: adds new search classes to search.py
This commit is contained in:
parent
657c775cbe
commit
5bc00f1143
3 changed files with 26 additions and 3 deletions
9
cognee/modules/search/exceptions/__init__.py
Normal file
9
cognee/modules/search/exceptions/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"""
|
||||
Custom exceptions for the Cognee API.
|
||||
|
||||
This module defines a set of exceptions for handling various data errors
|
||||
"""
|
||||
|
||||
from .exceptions import (
|
||||
UnsupportedSearchTypeError
|
||||
)
|
||||
15
cognee/modules/search/exceptions/exceptions.py
Normal file
15
cognee/modules/search/exceptions/exceptions.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from cognee.exceptions import (
|
||||
CogneeValidationError,
|
||||
)
|
||||
from fastapi import status
|
||||
|
||||
|
||||
class UnsupportedSearchTypeError(CogneeValidationError):
|
||||
def __init__(
|
||||
self,
|
||||
search_type: str,
|
||||
name: str = "UnsupportedSearchTypeError",
|
||||
status_code: int = status.HTTP_400_BAD_REQUEST,
|
||||
):
|
||||
message = f"Unsupported search type: {search_type}"
|
||||
super().__init__(message, name, status_code)
|
||||
|
|
@ -3,9 +3,8 @@ import json
|
|||
import asyncio
|
||||
from uuid import UUID
|
||||
from typing import Callable, List, Optional, Type, Union
|
||||
|
||||
from cognee.modules.search.exceptions import UnsupportedSearchTypeError
|
||||
from cognee.context_global_variables import set_database_global_context_variables
|
||||
from cognee.exceptions import InvalidValueError
|
||||
from cognee.modules.retrieval.chunks_retriever import ChunksRetriever
|
||||
from cognee.modules.retrieval.insights_retriever import InsightsRetriever
|
||||
from cognee.modules.retrieval.summaries_retriever import SummariesRetriever
|
||||
|
|
@ -136,7 +135,7 @@ async def specific_search(
|
|||
search_task = search_tasks.get(query_type)
|
||||
|
||||
if search_task is None:
|
||||
raise InvalidValueError(message=f"Unsupported search type: {query_type}")
|
||||
raise UnsupportedSearchTypeError(str(query_type))
|
||||
|
||||
send_telemetry("cognee.search EXECUTION STARTED", user.id)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue