add none to default as observability
This commit is contained in:
parent
57c6717b04
commit
3426f23452
3 changed files with 23 additions and 1 deletions
|
|
@ -10,13 +10,20 @@ import pydantic
|
||||||
class BaseConfig(BaseSettings):
|
class BaseConfig(BaseSettings):
|
||||||
data_root_directory: str = get_absolute_path(".data_storage")
|
data_root_directory: str = get_absolute_path(".data_storage")
|
||||||
system_root_directory: str = get_absolute_path(".cognee_system")
|
system_root_directory: str = get_absolute_path(".cognee_system")
|
||||||
monitoring_tool: object = Observer.LANGFUSE
|
monitoring_tool: object = Observer.NONE
|
||||||
|
|
||||||
@pydantic.model_validator(mode="after")
|
@pydantic.model_validator(mode="after")
|
||||||
def validate_paths(self):
|
def validate_paths(self):
|
||||||
# Require absolute paths for root directories
|
# Require absolute paths for root directories
|
||||||
self.data_root_directory = ensure_absolute_path(self.data_root_directory)
|
self.data_root_directory = ensure_absolute_path(self.data_root_directory)
|
||||||
self.system_root_directory = ensure_absolute_path(self.system_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
|
return self
|
||||||
|
|
||||||
langfuse_public_key: Optional[str] = os.getenv("LANGFUSE_PUBLIC_KEY")
|
langfuse_public_key: Optional[str] = os.getenv("LANGFUSE_PUBLIC_KEY")
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,17 @@ def get_observe():
|
||||||
from langfuse.decorators import observe
|
from langfuse.decorators import observe
|
||||||
|
|
||||||
return 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
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from enum import Enum
|
||||||
class Observer(str, Enum):
|
class Observer(str, Enum):
|
||||||
"""Monitoring tools"""
|
"""Monitoring tools"""
|
||||||
|
|
||||||
|
NONE = "none"
|
||||||
LANGFUSE = "langfuse"
|
LANGFUSE = "langfuse"
|
||||||
LLMLITE = "llmlite"
|
LLMLITE = "llmlite"
|
||||||
LANGSMITH = "langsmith"
|
LANGSMITH = "langsmith"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue