From 0c6780d66e5f208bc4806ab227990d15af400776 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 28 Jun 2024 15:06:05 +0100 Subject: [Minor] Make except symbols configurable --- src/plugins/lua/gpt.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 3e3a6737d..ca39794c5 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -55,6 +55,15 @@ local rspamd_http = require "rspamd_http" local rspamd_logger = require "rspamd_logger" local ucl = require "ucl" +-- Exclude checks if one of those is found +local default_symbols_to_except = { + 'BAYES_SPAM', -- We already know that it is a spam, so we can safely skip it, but no same logic for HAM! + 'WHITELIST_SPF', + 'WHITELIST_DKIM', + 'WHITELIST_DMARC', + 'FUZZY_DENIED', +} + local settings = { type = 'openai', api_key = nil, @@ -67,15 +76,7 @@ local settings = { condition = nil, autolearn = false, url = 'https://api.openai.com/v1/chat/completions', -} - --- Exclude checks if one of those is found -local symbols_to_except = { - 'BAYES_SPAM', -- We already know that it is a spam, so we can safely skip it, but no same logic for HAM! - 'WHITELIST_SPF', - 'WHITELIST_DKIM', - 'WHITELIST_DMARC', - 'FUZZY_DENIED', + symbols_to_except = default_symbols_to_except, } local function default_condition(task) @@ -100,7 +101,7 @@ local function default_condition(task) end end -- We also exclude some symbols - for _, s in ipairs(symbols_to_except) do + for _, s in ipairs(settings.symbols_to_except) do if task:has_symbol(s) then return false, 'skip as "' .. s .. '" is found' end -- cgit v1.2.3