]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Update gpt.lua to make use of lua_util.deepcopy function.
authorhunter-nl <junobox@gmail.com>
Fri, 15 Aug 2025 14:21:36 +0000 (16:21 +0200)
committerGitHub <noreply@github.com>
Fri, 15 Aug 2025 14:21:36 +0000 (16:21 +0200)
src/plugins/lua/gpt.lua

index 8457fbdf75d756e3686bd527d640171471979100..b013f91c71a84dac811b6c6372577bdad922c956 100644 (file)
@@ -683,21 +683,7 @@ 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
+    -- Decide which token length field to use for the given model
   local function get_max_tokens_field(model)
     if not model then
       return 'max_tokens' -- default
@@ -766,7 +752,7 @@ local function openai_check(task, content, sel_part)
       checked = false
     }
     -- Fresh body for each model
-    local body = table_deep_copy(body_base)
+    local body = lua_util.deepcopy(body_base)
 
     -- Set the correct token limit field
     local token_field = get_max_tokens_field(model)