From: hunter-nl Date: Thu, 14 Aug 2025 14:03:43 +0000 (+0200) Subject: Update gpt.lua to get fresh body for each model iteration X-Git-Tag: 3.13.0~29^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=588e74931c00bdb5f929259e0aad5f122386bae4;p=thirdparty%2Frspamd.git Update gpt.lua to get fresh body for each model iteration --- diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 235984aa9b..0738bb5ab8 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -683,6 +683,20 @@ local function openai_check(task, content, sel_part) local from_content, url_content = get_meta_llm_content(task) + -- Deep copy to avoid table reuse between iterations + local function table_deep_copy(orig) + local copy + if type(orig) == 'table' then + copy = {} + for k, v in pairs(orig) do + copy[k] = table_deep_copy(v) + end + else + copy = orig + end + return copy + end + -- Decide which token length field to use for the given model local function get_max_tokens_field(model) if not model then @@ -751,7 +765,9 @@ local function openai_check(task, content, sel_part) success = false, checked = false } - local body = body_base + -- Fresh body for each model + local body = table_deep_copy(body_base) + -- Set the correct token limit field local token_field = get_max_tokens_field(model) body[token_field] = settings.max_tokens