diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e3051ca --- /dev/null +++ b/__init__.py @@ -0,0 +1,2 @@ +# This file marks the directory as a Python package +# It allows Python to properly import modules from this directory diff --git a/gurt/__init__.py b/gurt/__init__.py index 2a841da..1a99e3f 100644 --- a/gurt/__init__.py +++ b/gurt/__init__.py @@ -1 +1,8 @@ # This file makes the 'gurt' directory a Python package. +# It allows Python to properly import modules from this directory + +# Export the setup function for discord.py extension loading +from .cog import setup + +# This makes "from gurt import setup" work +__all__ = ['setup'] diff --git a/gurt/cog.py b/gurt/cog.py index b1efce9..935a6a4 100644 --- a/gurt/cog.py +++ b/gurt/cog.py @@ -29,7 +29,7 @@ from .config import ( EVOLUTION_UPDATE_INTERVAL, RESPONSE_SCHEMA, TOOLS # Import necessary configs ) # Import functions/classes from other modules -from ..gurt_memory import MemoryManager # Go up one level +from .memory import MemoryManager # Import from local memory.py from .background import background_processing_task from .commands import setup_commands # Import the setup helper from .listeners import on_ready_listener, on_message_listener, on_reaction_add_listener, on_reaction_remove_listener # Import listener functions diff --git a/gurt/memory.py b/gurt/memory.py new file mode 100644 index 0000000..4a0c2d6 --- /dev/null +++ b/gurt/memory.py @@ -0,0 +1,19 @@ +# Import the MemoryManager from the parent directory +# Use a direct import path that doesn't rely on package structure +import os +import importlib.util + +# Get the absolute path to gurt_memory.py +parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +gurt_memory_path = os.path.join(parent_dir, 'gurt_memory.py') + +# Load the module dynamically +spec = importlib.util.spec_from_file_location('gurt_memory', gurt_memory_path) +gurt_memory = importlib.util.module_from_spec(spec) +spec.loader.exec_module(gurt_memory) + +# Import the MemoryManager class from the loaded module +MemoryManager = gurt_memory.MemoryManager + +# Re-export the MemoryManager class +__all__ = ['MemoryManager'] diff --git a/gurt/prompt.py b/gurt/prompt.py index 5fe9aff..4db0793 100644 --- a/gurt/prompt.py +++ b/gurt/prompt.py @@ -10,7 +10,7 @@ from .config import ( BASELINE_PERSONALITY, MOOD_OPTIONS, CHANNEL_TOPIC_CACHE_TTL, INTEREST_MAX_FOR_PROMPT, INTEREST_MIN_LEVEL_FOR_PROMPT ) -from ..gurt_memory import MemoryManager # Go up one level to import MemoryManager +from .memory import MemoryManager # Import from local memory.py if TYPE_CHECKING: from .cog import GurtCog # Import GurtCog for type hinting only diff --git a/gurt/tools.py b/gurt/tools.py index cbba051..74a1ce2 100644 --- a/gurt/tools.py +++ b/gurt/tools.py @@ -19,7 +19,7 @@ import docker import docker.aio # Relative imports from within the gurt package and parent -from ..gurt_memory import MemoryManager # Go up one level +from .memory import MemoryManager # Import from local memory.py from .config import ( TAVILY_API_KEY, PISTON_API_URL, PISTON_API_KEY, SAFETY_CHECK_MODEL, DOCKER_EXEC_IMAGE, DOCKER_COMMAND_TIMEOUT, DOCKER_CPU_LIMIT, DOCKER_MEM_LIMIT,