smares
The instructions in mailcow docs are about new modules, not included in rspamd. GPT plugin is included already in rspamd-mailcow. So basically, it’s needed to be created a new config file: data/conf/rspamd/local.d/gpt.conf
Open the file and fill the configuration parameters:
enabled = true; # Enable the plugin
type = “openai”; # Supported types: openai, ollama
api_key = “xxx”; # Your key to access the API
model = “gpt-4o-mini”; # Model name
max_tokens = 1000; # Maximum tokens to generate
temperature = 0.0; # Temperature for sampling
timeout = 10s; # Timeout for requests
prompt = “xxx”; # Prompt for the model (use default if not set)
condition = “xxx”; # Custom condition (lua function)
autolearn = true; # Autolearn if gpt classified
reply_conversion = “xxx”; # Reply conversion (lua code)
url = “https://api.openai.com/v1/chat/completions”; # URL for the API
allow_passthrough = false; # Check messages with passthrough result
allow_ham = false; # Check messages that are apparent ham (no action and negative score)
reason_header = “X-GPT-Reason”; # Add header with reason (null to disable)
json = false; # Use JSON format for response
Restarting rspamd-mailcow will load the gpt.lua plugin and if loading is successfull, you can view this messages in the rspamd-mailcow logs:
rspamd-mailcow-1 | 2025-02-28 23:41:30 #1(main) <1n5m8f>; lua; lua_redis.lua:605: use default Redis settings for gpt
rspamd-mailcow-1 | 2025-02-28 23:41:30 #1(main) <1n5m8f>; cfg; rspamd_init_lua_filters: init lua module gpt from /usr/share/rspamd/plugins/gpt.lua; digest: bfd7f51817
I am in testing a ollama model, but i get errors like this one:
call to (GPT_CHECK) failed (2): /usr/share/rspamd/plugins/gpt.lua:192: attempt to call field 'get_displayed_text_part' (a nil value); trace: [1]:{/usr/share/rspamd/plugins/gpt.lua:192 - condition [Lua]}; [2]:{/usr/share/rspamd/plugins/gpt.lua:854 - <unknown> [Lua]};
…and can’t understand if gpt plugin for now support only openai, or ollama support is also implemented completely, but my configuration of the config file is wrong somehow?