import os

from mem0x import Memory, ShortTermMemory
from mem0x.configs.base import MemoryConfig, ShortTermMemoryConfig


def read_file_content(file_path: str):
    with open(file_path, "r", encoding="utf-8") as file:
        content = file.read()
        return content
    return None


class MemoryInstance:
    def __init__(self):
        self.m_config = MemoryConfig()
        self.m = Memory(self.m_config)

        self.sm_config = ShortTermMemoryConfig()
        self.sm = ShortTermMemory(self.sm_config)

        custom_prompt_file_path = os.getenv("LONGTERM_CUSTOM_PROMPT_FILE_PATH")
        if custom_prompt_file_path is not None:
            self.longterm_custom_prompt = read_file_content(custom_prompt_file_path)
        else:
            self.longterm_custom_prompt = None

        custom_prompt_file_path = os.getenv("BOOTSTRAP_CUSTOM_PROMPT_FILE_PATH")
        if custom_prompt_file_path is not None:
            self.bootstrap_custom_prompt = read_file_content(custom_prompt_file_path)
        else:
            self.bootstrap_custom_prompt = None


memoryInstance = MemoryInstance()
