Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Feature/posthog (#389)
Louis Choquelbffbe2356cd7
diff --git a/pipelex/pipe_operators/func/pipe_func_blueprint.py b/pipelex/pipe_operators/func/pipe_func_blueprint.pyindex 723d9a657..5e7e83fa4 100644--- a/pipelex/pipe_operators/func/pipe_func_blueprint.py+++ b/pipelex/pipe_operators/func/pipe_func_blueprint.py@@ -9,3 +9,5 @@ class PipeFuncBlueprint(PipeBlueprint):type: Literal["PipeFunc"] = "PipeFunc"pipe_category: Literal["PipeOperator"] = "PipeOperator"function_name: str = Field(description="The name of the function to call.")++ # TODO: validate function_namediff --git a/pipelex/pipe_operators/func/pipe_func_factory.py b/pipelex/pipe_operators/func/pipe_func_factory.pyindex 3a848b332..75eb47b3b 100644--- a/pipelex/pipe_operators/func/pipe_func_factory.py+++ b/pipelex/pipe_operators/func/pipe_func_factory.py@@ -27,6 +27,7 @@ class PipeFuncFactory(PipeFactoryProtocol[PipeFuncBlueprint, PipeFunc]):concept_string_or_code=output_parse_result.concept,concept_codes_from_the_same_domain=concept_codes_from_the_same_domain,)+ # TODO: make function_name into a callable in PipeFuncreturn PipeFunc(domain=domain,code=pipe_code,diff --git a/pipelex/system/registries/func_registry.py b/pipelex/system/registries/func_registry.pyindex e9abaff1a..ccbf0e14b 100644--- a/pipelex/system/registries/func_registry.py+++ b/pipelex/system/registries/func_registry.py@@ -163,6 +163,7 @@ class FuncRegistry(RootModel[FuncRegistryDict]):"""return hasattr(func, PIPE_FUNC_MARKER) and getattr(func, PIPE_FUNC_MARKER) is True+ # TODO: refactor this into a subclass of FuncRegistry dedicated to pipe funcs, avoid the circular import issue, avoid the code-smelldef is_eligible_function(self, func: Any, require_decorator: bool = False) -> bool:"""Checks if a function matches the criteria for PipeFunc registration:- Must be callable@@ -187,59 +188,54 @@ class FuncRegistry(RootModel[FuncRegistryDict]):the_function = cast("Callable[..., Any]", func)- try:- # Import here to avoid circular imports- # TODO: code-smell- from pipelex.core.memory.working_memory import WorkingMemory # noqa: PLC0415- from pipelex.core.stuffs.stuff_content import StuffContent # noqa: PLC0415+ # Import here to avoid circular imports+ # TODO: code-smell+ from pipelex.core.memory.working_memory import WorkingMemory # noqa: PLC0415+ from pipelex.core.stuffs.stuff_content import StuffContent # noqa: PLC0415- # Get function signature- sig = inspect.signature(the_function)- params = list(sig.parameters.values())+ # Get function signature+ sig = inspect.signature(the_function)+ params = list(sig.parameters.values())- # Check parameter count and name- if len(params) != 1:- return False+ # Check parameter count and name+ if len(params) != 1:+ return False- param = params[0]- if param.name != "working_memory":- return False+ param = params[0]+ if param.name != "working_memory":+ return False- # Get type hints- type_hints = get_type_hints(the_function)+ # Get type hints+ type_hints = get_type_hints(the_function)- # Check parameter type- if "working_memory" not in type_hints:- return False+ # Check parameter type+ if "working_memory" not in type_hints:+ return False- param_type = type_hints["working_memory"]- if param_type != WorkingMemory:- return False+ param_type = type_hints["working_memory"]+ if param_type != WorkingMemory:+ return False- # Check return type- if "return" not in type_hints:- return False+ # Check return type+ if "return" not in type_hints:+ return False- return_type = type_hints["return"]+ return_type = type_hints["return"]- # Check if return type is a subclass of StuffContent- try:- if inspect.isclass(return_type) and issubclass(return_type, StuffContent):+ # Check if return type is a subclass of StuffContent+ try:+ if inspect.isclass(return_type) and issubclass(return_type, StuffContent):+ return True+ # Handle generic types like ListContent[SomeType]+ if hasattr(return_type, "__origin__"):+ origin = return_type.__origin__+ if inspect.isclass(origin) and issubclass(origin, StuffContent):return True- # Handle generic types like ListContent[SomeType]- if hasattr(return_type, "__origin__"):- origin = return_type.__origin__- if inspect.isclass(origin) and issubclass(origin, StuffContent):- return True- except TypeError:- # Handle cases where issubclass fails on generic types- pass+ except TypeError:+ # Handle cases where issubclass fails on generic types+ pass- return False-- except Exception:- # If we can't analyze the function, skip it- return False+ return Falsefunc_registry = FuncRegistry()