Merge pull request #212 from bucolucas/feature/add-bot-status-method
Add get_bot_status to InferenceBot and OpenAICompatibleInferenceBot
This commit is contained in:
@@ -62,5 +62,7 @@ async def button_callback(update: Update, context: ContextTypes.DEFAULT_TYPE) ->
|
|||||||
# Handle file selection
|
# Handle file selection
|
||||||
file_path = data.split(":")[1]
|
file_path = data.split(":")[1]
|
||||||
os.environ['SYSTEM_PROMPT_PATH'] = file_path
|
os.environ['SYSTEM_PROMPT_PATH'] = file_path
|
||||||
|
if hasattr(browse_command_bot, 'system_prompt_path'):
|
||||||
|
browse_command_bot.system_prompt_path = file_path
|
||||||
browse_command_bot.system_prompt = browse_command_bot.load_system_prompt()
|
browse_command_bot.system_prompt = browse_command_bot.load_system_prompt()
|
||||||
await query.edit_message_text(f"Selected: {file_path}. System prompt updated.")
|
await query.edit_message_text(f"Selected: {file_path}. System prompt updated.")
|
||||||
@@ -44,3 +44,8 @@ class InferenceBot(ABC):
|
|||||||
Example usage in subclass: self.processing_status.get(user_id)
|
Example usage in subclass: self.processing_status.get(user_id)
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_bot_status(self):
|
||||||
|
"""Returns a human-readable message describing the model in use and the system prompt path."""
|
||||||
|
pass
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class OpenAICompatibleInferenceBot(InferenceBot):
|
|||||||
self.allowed_function_tags = allowed_function_tags if allowed_function_tags else None
|
self.allowed_function_tags = allowed_function_tags if allowed_function_tags else None
|
||||||
self.conversation_history = {}
|
self.conversation_history = {}
|
||||||
self._processing_status = {}
|
self._processing_status = {}
|
||||||
|
self.system_prompt_path = system_prompt_path # Store the prompt path for status
|
||||||
# MODIFIED to pass arguments
|
# MODIFIED to pass arguments
|
||||||
self.system_prompt = self.load_system_prompt(
|
self.system_prompt = self.load_system_prompt(
|
||||||
file_path=system_prompt_path
|
file_path=system_prompt_path
|
||||||
@@ -118,6 +119,14 @@ class OpenAICompatibleInferenceBot(InferenceBot):
|
|||||||
logging.error(f"API call to model {self.model} failed: {e}")
|
logging.error(f"API call to model {self.model} failed: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def get_bot_status(self):
|
||||||
|
"""
|
||||||
|
Returns a message with the currently enabled model and the system prompt path being used.
|
||||||
|
"""
|
||||||
|
model_name = self.model if hasattr(self, 'model') else None
|
||||||
|
prompt_path = self.system_prompt_path or os.getenv("SYSTEM_PROMPT_PATH") or "(default prompt in use)"
|
||||||
|
return f"Current model: {model_name}\nSystem prompt path: {prompt_path}"
|
||||||
|
|
||||||
async def handle_message(self, user_id, user_message):
|
async def handle_message(self, user_id, user_message):
|
||||||
if user_id not in self.conversation_history or not self.conversation_history[user_id]:
|
if user_id not in self.conversation_history or not self.conversation_history[user_id]:
|
||||||
self.conversation_history[user_id] = []
|
self.conversation_history[user_id] = []
|
||||||
@@ -281,7 +290,7 @@ class OpenAICompatibleInferenceBot(InferenceBot):
|
|||||||
if function_call_arguments is None:
|
if function_call_arguments is None:
|
||||||
function_args = {}
|
function_args = {}
|
||||||
else:
|
else:
|
||||||
logging.error(f"Unexpected type for function_call_arguments for {function_call_name}: {type(function_call_arguments)}. Arguments: {function_call_arguments}")
|
logging.error(f"Unexpected type for function_call_arguments for {function_name}: {type(function_call_arguments)}. Arguments: {function_call_arguments}")
|
||||||
return f"Error: Invalid argument type for tool call: {type(function_call_arguments)}"
|
return f"Error: Invalid argument type for tool call: {type(function_call_arguments)}"
|
||||||
|
|
||||||
for tool in self.tools:
|
for tool in self.tools:
|
||||||
|
|||||||
Reference in New Issue
Block a user