Merge pull request #155 from bucolucas/issue-154-implement-file-selection
Implement File Selection to Update SYSTEM_PROMPT_PATH
This commit is contained in:
@@ -14,8 +14,12 @@ class BaseTelegramInferenceBot(ABC):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_system_prompt():
|
def load_system_prompt():
|
||||||
with open(os.environ.get("SYSTEM_PROMPT_PATH"), "r", encoding="utf-8") as file:
|
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()
|
return file.read().strip()
|
||||||
|
else:
|
||||||
|
raise FileNotFoundError("SYSTEM_PROMPT_PATH is not set or file does not exist.")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_functions():
|
def load_functions():
|
||||||
@@ -52,7 +56,7 @@ class BaseTelegramInferenceBot(ABC):
|
|||||||
|
|
||||||
def call_tool(self, function_call_name, function_call_arguments):
|
def call_tool(self, function_call_name, function_call_arguments):
|
||||||
function_name = function_call_name
|
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:
|
for tool in self.tools:
|
||||||
if function_name in [f["name"] for f in tool.get_functions()]:
|
if function_name in [f["name"] for f in tool.get_functions()]:
|
||||||
return tool.execute(function_name, **function_args)
|
return tool.execute(function_name, **function_args)
|
||||||
|
|||||||
+7
-2
@@ -40,6 +40,11 @@ async def button_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
|
|||||||
subdir = data.split(":")[1]
|
subdir = data.split(":")[1]
|
||||||
await query.edit_message_text(f"Navigating to [{subdir}] is not yet implemented.")
|
await query.edit_message_text(f"Navigating to [{subdir}] is not yet implemented.")
|
||||||
elif data.startswith("file:"):
|
elif data.startswith("file:"):
|
||||||
# Handle file selection (for future implementation)
|
# Handle file selection
|
||||||
file = data.split(":")[1]
|
file = data.split(":")[1]
|
||||||
await query.edit_message_text(f"Viewing contents of {file} is not yet implemented.")
|
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.
|
||||||
Reference in New Issue
Block a user