from typing import Any

from pandasai.pipelines.base_logic_unit import BaseLogicUnit


class BaseCodeExecutor(BaseLogicUnit):
    """
    Executes the code generated by the prompt
    """

    def execute(self, input: Any, **kwargs) -> Any:
        # Create an empty namespace dictionary
        namespace = {}

        # Execute the code to populate the namespace
        exec(input, namespace)

        return namespace
