From c80d6b3cfd9d357e5f0d2a9417deb16bdd72dcde Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rene=CC=81=20Draaisma?= Date: Sat, 16 Aug 2025 10:55:40 +0200 Subject: [PATCH] Updated gpt.lua to set default gpt-5-mini as model, fix issue when GPT max_completion_tokens exceeded and returned empty reason field, Set default group to GPT for Symbols, group is now also configurable in settings with extra_symbols, fix issue when no score is defined in settings at extra_symbols, default score is now 0 --- src/plugins/lua/gpt.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 903f15db63..a2e7dde3d0 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -116,7 +116,7 @@ local categories_map = {} local settings = { type = 'openai', api_key = nil, - model = 'gpt-5-mini', + model = 'gpt-5-mini', -- or parallel model requests: [ 'gpt-5-mini', 'gpt-4o-mini' ], model_parameters = { ["gpt-5-mini"] = { max_completion_tokens = 1000, @@ -373,7 +373,7 @@ local function default_openai_plain_conversion(task, input) local first_message = reply.choices[1].message.content - if not first_message then + if not first_message or first_message == "" then rspamd_logger.errx(task, 'no content in the first message') return end @@ -702,6 +702,7 @@ local function openai_check(task, content, sel_part) local from_content, url_content = get_meta_llm_content(task) + local body_base = { messages = { { @@ -959,7 +960,6 @@ if opts then if not settings.api_key and llm_type.require_passkey then rspamd_logger.warnx(rspamd_config, 'no api_key is specified for LLM type %s, disabling module', settings.type) lua_util.disable_module(N, "config") - return end @@ -978,12 +978,14 @@ if opts then type = 'virtual', parent = id, score = 3.0, + group = 'GPT', }) rspamd_config:register_symbol({ name = 'GPT_HAM', type = 'virtual', parent = id, score = -2.0, + group = 'GPT', }) if settings.extra_symbols then @@ -992,7 +994,8 @@ if opts then name = sym, type = 'virtual', parent = id, - score = data.score, + score = data.score or 0, + group = data.group or 'GPT', description = data.description, }) data.name = sym -- 2.47.3