diff --git a/telegram_inference_bot.py b/telegram_inference_bot.py index 97f3b02..f535faa 100644 --- a/telegram_inference_bot.py +++ b/telegram_inference_bot.py @@ -19,11 +19,22 @@ client = OpenAI() GPT_4O = "gpt-4o" GPT_4O_MINI = "gpt-4o-mini" +class StringFilter(logging.Filter): + def __init__(self, strings_to_filter): + super().__init__() + self.strings_to_filter = strings_to_filter + + def filter(self, record): + return not any(s in record.getMessage() for s in self.strings_to_filter) + +strings_to_filter = ['unwanted_string_1', 'unwanted_string_2'] # Change these to the specific strings you want to filter out + # Set up logging to console and file logging.basicConfig(level=logging.INFO, handlers=[ logging.StreamHandler(), logging.FileHandler('logs/output.log', mode='a') ]) +logging.getLogger().addFilter(StringFilter(strings_to_filter)) # Set up Telegram bot TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN')