diff --git a/base_telegram_inference_bot.py b/base_telegram_inference_bot.py index 2033474..a9b7b52 100644 --- a/base_telegram_inference_bot.py +++ b/base_telegram_inference_bot.py @@ -14,8 +14,12 @@ class BaseTelegramInferenceBot(ABC): @staticmethod def load_system_prompt(): - with open(os.environ.get("SYSTEM_PROMPT_PATH"), "r", encoding="utf-8") as file: - return file.read().strip() + system_prompt_path = os.getenv("SYSTEM_PROMPT_PATH") + if system_prompt_path and os.path.isfile(system_prompt_path): + with open(system_prompt_path, "r", encoding="utf-8") as file: + return file.read().strip() + else: + raise FileNotFoundError("SYSTEM_PROMPT_PATH is not set or file does not exist.") @staticmethod def load_functions(): @@ -52,7 +56,7 @@ class BaseTelegramInferenceBot(ABC): def call_tool(self, function_call_name, function_call_arguments): function_name = function_call_name - function_args = json.loads(function_call_arguments if function_call_arguments is not None else "{}") + function_args = json.loads(function_call_arguments if function_call_arguments is not None else "{}"). for tool in self.tools: if function_name in [f["name"] for f in tool.get_functions()]: return tool.execute(function_name, **function_args) diff --git a/browse_command.py b/browse_command.py index b77e5f9..7be5a78 100644 --- a/browse_command.py +++ b/browse_command.py @@ -40,6 +40,11 @@ async def button_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) -> subdir = data.split(":")[1] await query.edit_message_text(f"Navigating to [{subdir}] is not yet implemented.") elif data.startswith("file:"): - # Handle file selection (for future implementation) + # Handle file selection file = data.split(":")[1] - await query.edit_message_text(f"Viewing contents of {file} is not yet implemented.") \ No newline at end of file + file_path = os.path.join('prompts', file) + os.environ['SYSTEM_PROMPT_PATH'] = file_path + await query.edit_message_text(f"Selected: {file}. SYSTEM_PROMPT_PATH updated.") + + # Optionally, you may want to reload the system prompt here if needed. + # bot.system_prompt = bot.load_system_prompt() # Uncomment if you have access to the bot instance. \ No newline at end of file