From 47f9cee7737d736ca32f5199ddb9df71a1bacc88 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 10:25:33 +0000 Subject: [PATCH] [Minor] Migrate src/plugins/lua/neural.lua to lua_shape MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Replace tableshape with lua_shape in neural plugin. Changes: - ts.shape { ... } → T.table({ ... }) - ts.string, ts.number → T.string(), T.number() - ts.array_of(x) → T.array(x) - :is_optional() → :optional() - Added comprehensive documentation to all fields Schema: redis_profile_schema for neural network profiles stored in Redis, including digest, symbols, version, and optional distance. --- src/plugins/lua/neural.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/lua/neural.lua b/src/plugins/lua/neural.lua index 3f0a3c7aa7..494ef43ef8 100644 --- a/src/plugins/lua/neural.lua +++ b/src/plugins/lua/neural.lua @@ -29,7 +29,7 @@ local rspamd_logger = require "rspamd_logger" local rspamd_tensor = require "rspamd_tensor" local rspamd_text = require "rspamd_text" local rspamd_util = require "rspamd_util" -local ts = require("tableshape").types +local T = require "lua_shape.core" -- Load providers pcall(require, "plugins/neural/providers/llm") pcall(require, "plugins/neural/providers/symbols") @@ -38,14 +38,14 @@ local N = "neural" local settings = neural_common.settings -local redis_profile_schema = ts.shape { - digest = ts.string, - symbols = ts.array_of(ts.string), - version = ts.number, - redis_key = ts.string, - distance = ts.number:is_optional(), - providers_digest = ts.string:is_optional(), -} +local redis_profile_schema = T.table({ + digest = T.string():doc({ summary = "Symbols digest" }), + symbols = T.array(T.string()):doc({ summary = "List of symbols" }), + version = T.number():doc({ summary = "Profile version" }), + redis_key = T.string():doc({ summary = "Redis key for ANN" }), + distance = T.number():optional():doc({ summary = "Distance metric" }), + providers_digest = T.string():optional():doc({ summary = "Providers digest" }), +}):doc({ summary = "Neural network profile schema" }) local has_blas = rspamd_tensor.has_blas() local text_cookie = rspamd_text.cookie -- 2.47.3