diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-07-22 13:33:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-07-22 13:33:37 +0100 |
commit | cb3faa71cade474d449cebf2896e81c083cde295 (patch) | |
tree | 71479c6a5170de2aa4272d842614185e7d0f9c7e /src/plugins | |
parent | 58d13149875a44329c54567387241b642cc96471 (diff) | |
download | rspamd-cb3faa71cade474d449cebf2896e81c083cde295.tar.gz rspamd-cb3faa71cade474d449cebf2896e81c083cde295.zip |
[Minor] Improve prompt and add some conversion heursitics
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/gpt.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index 65b5758a8..5e19d2998 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -194,6 +194,18 @@ local function default_conversion(task, input) if type(reply) == 'table' and reply.probability then local spam_score = tonumber(reply.probability) + + if not spam_score then + -- Maybe we need GPT to convert GPT reply here? + if reply.probability == "high" then + spam_score = 0.9 + elseif reply.probability == "low" then + spam_score = 0.1 + else + rspamd_logger.infox("cannot convert to spam probability: %s", reply.probability) + end + end + if type(reply.usage) == 'table' then rspamd_logger.infox(task, 'usage: %s tokens', reply.usage.total_tokens) end @@ -347,8 +359,8 @@ if opts then end if not settings.prompt then - settings.prompt = "You will be provided with the email message, " .. - "and your task is to classify its probability to be spam, " .. + settings.prompt = "You will be provided with the email message, subject, from and url domains, " .. + "and your task is to evaluate the probability to be spam as number from 0 to 1, " .. "output result as JSON with 'probability' field." end |