feat: adds configattributeerror
This commit is contained in:
parent
ebd4403c2f
commit
657c775cbe
3 changed files with 26 additions and 4 deletions
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from cognee.base_config import get_base_config
|
from cognee.base_config import get_base_config
|
||||||
from cognee.exceptions import InvalidValueError, InvalidAttributeError
|
|
||||||
from cognee.modules.cognify.config import get_cognify_config
|
from cognee.modules.cognify.config import get_cognify_config
|
||||||
from cognee.infrastructure.data.chunking.config import get_chunk_config
|
from cognee.infrastructure.data.chunking.config import get_chunk_config
|
||||||
from cognee.infrastructure.databases.vector import get_vectordb_config
|
from cognee.infrastructure.databases.vector import get_vectordb_config
|
||||||
|
|
@ -11,6 +10,7 @@ from cognee.infrastructure.llm.config import (
|
||||||
get_llm_config,
|
get_llm_config,
|
||||||
)
|
)
|
||||||
from cognee.infrastructure.databases.relational import get_relational_config, get_migration_config
|
from cognee.infrastructure.databases.relational import get_relational_config, get_migration_config
|
||||||
|
from cognee.api.v1.exceptions.exceptions import InvalidConfigAttributeError
|
||||||
|
|
||||||
|
|
||||||
class config:
|
class config:
|
||||||
|
|
@ -92,9 +92,7 @@ class config:
|
||||||
if hasattr(llm_config, key):
|
if hasattr(llm_config, key):
|
||||||
object.__setattr__(llm_config, key, value)
|
object.__setattr__(llm_config, key, value)
|
||||||
else:
|
else:
|
||||||
raise InvalidAttributeError(
|
raise InvalidConfigAttributeError(attribute=key)
|
||||||
message=f"'{key}' is not a valid attribute of the config."
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_chunk_strategy(chunk_strategy: object):
|
def set_chunk_strategy(chunk_strategy: object):
|
||||||
|
|
|
||||||
9
cognee/api/v1/exceptions/__init__.py
Normal file
9
cognee/api/v1/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 (
|
||||||
|
InvalidConfigAttributeError
|
||||||
|
)
|
||||||
15
cognee/api/v1/exceptions/exceptions.py
Normal file
15
cognee/api/v1/exceptions/exceptions.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from cognee.exceptions import (
|
||||||
|
CogneeConfigurationError,
|
||||||
|
)
|
||||||
|
from fastapi import status
|
||||||
|
|
||||||
|
|
||||||
|
class InvalidConfigAttributeError(CogneeConfigurationError):
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
attribute: str,
|
||||||
|
name: str = "InvalidConfigAttributeError",
|
||||||
|
status_code: int = status.HTTP_400_BAD_REQUEST,
|
||||||
|
):
|
||||||
|
message = f"'{attribute}' is not a valid attribute of the configuration."
|
||||||
|
super().__init__(message, name, status_code)
|
||||||
Loading…
Add table
Reference in a new issue