add none to default as observability

This commit is contained in:
Hande 2025-09-18 10:41:25 +02:00
parent 57c6717b04
commit 3426f23452
3 changed files with 23 additions and 1 deletions

View file

@ -10,13 +10,20 @@ import pydantic
class BaseConfig(BaseSettings):
data_root_directory: str = get_absolute_path(".data_storage")
system_root_directory: str = get_absolute_path(".cognee_system")
monitoring_tool: object = Observer.LANGFUSE
monitoring_tool: object = Observer.NONE
@pydantic.model_validator(mode="after")
def validate_paths(self):
# Require absolute paths for root directories
self.data_root_directory = ensure_absolute_path(self.data_root_directory)
self.system_root_directory = ensure_absolute_path(self.system_root_directory)
# Set monitoring tool based on available keys
if self.langfuse_public_key and self.langfuse_secret_key:
self.monitoring_tool = Observer.LANGFUSE
else:
self.monitoring_tool = Observer.NONE
return self
langfuse_public_key: Optional[str] = os.getenv("LANGFUSE_PUBLIC_KEY")

View file

@ -9,3 +9,17 @@ def get_observe():
from langfuse.decorators import observe
return observe
elif monitoring == Observer.NONE:
# Return a no-op decorator that handles keyword arguments
def no_op_decorator(*args, **kwargs):
if len(args) == 1 and callable(args[0]) and not kwargs:
# Direct decoration: @observe
return args[0]
else:
# Parameterized decoration: @observe(as_type="generation")
def decorator(func):
return func
return decorator
return no_op_decorator

View file

@ -4,6 +4,7 @@ from enum import Enum
class Observer(str, Enum):
"""Monitoring tools"""
NONE = "none"
LANGFUSE = "langfuse"
LLMLITE = "llmlite"
LANGSMITH = "langsmith"