Discourse AI Topic Summary : automated summaries and smart tagging

Tired of tagging Topics? Let the AI do it for you! (Relatively intelligently!)

I’ve added EXPERIMENTAL auto-tagging support that will apply tags to your topic based on its content.

Sometimes the AI gets too creative despite the direction we are giving it here , so you can restrict it to the set of existing ones.

you can quickly create a non-admin user for this purpose from the rails console by using:

rake admin:create (don’t give this user admin priviliges!)

(This is a bit of a hacky workaround because the current Discourse “internal API” for tagging currently does not allow you to specify “no new tags”, so the only way of easily preventing this at present is by creating them as a user that does not have that privilege (ie trust level less that min_trust_to_create_tag)


James, you (and others) might be interested in this:

I’m currently experimenting with it and will merge it soon:

  • FEATURE: Adds ability to use ChatGPT (faster and cheaper) inc. GPT-4
  • FEATURE: Adds ability to specify model name so you can specify a custom model name if it exists in Open AI namespace.
  • FEATURE: Add settings to affect style of response

(Just for summaries at this stage, not for Tag determination)

This was mainly prompted by this communication:

So now you can specify the new ChatGPT model (“gpt-3.5-turbo-16k”) in the custom model name and should be able to summarise around… :drum: :drum: :drum:

=== > 160 Post Topics! (increase of 4x!!) < ===



OK that PR is merged post Production checkout. Let me know if anyone has any problems.


Hi @merefield,

Thanks for the update. I’ll check the changes out.

The new function capability is something we are looking at too. The idea of being able to get consistent structured data back from the api call is very exciting! And who could complain about longer context


To your original point though, use of gpt-3.5-16k is nearly 7x cheaper than using Davinci for this purpose despite the huge increase in context.

I have already seen a “flattening” of my price curve in the last 24 hours.


If I have the chatbot installed, the AIBot - could I set the user to that one and reuse the token from that plugin`?


You can re-use the token, yes, no problem.

The user in this plugin is only used to restrict tag choice … if you re-use the same AIBot user it will likely have rights to create new tags because it will probably have high privilege in order to post everywhere. I’ve not tried it but perhaps you can keep AIBot at a low TL.

If you don’t mind it creating new tags then that’s ok, but results are usually better if you prevent it from doing so.

1 Like

My AIBot is TL 4

And have admin rights - it seems like…

Will the plugin work on old posts or only new one?

1 Like

Yeah, I’d create or borrow another user who is TL2 use that. Lock their Trust Level. And restrict create new Tags to TL3.

It will work on old Topics … but it is triggered by new Posts.

1 Like

It is working - but it doesnt read the forum language - the summery is in english.

1 Like

You’ll likely need to update the prompts and ask it to summarise in your chosen language.

These can be changed in Customize → Text

1 Like

Ahh the summery it self is in english.

Also seems like I have tagging error issue :S

1 Like

This is no surprise if you haven’t restricted tag creation as recommended.

I’ve had this working for months and it can be amazingly clever :).

1 Like

Apologies @frold you were right.

And sorry this took so long to reproduce, focus on and fix, but it should work now with Chat model:

The issue was I was not using the Chat model for tagging until recently … and then it took me some time to notice there was a problem.


sudo ./launcher rebuild app,You are specifying the gem tokenizers in /var/www/discourse/plugins/discourse-ai/plugin.rb, however it does not exist!

discourse-topic-voting is already at latest compatible version
discourse-translator is already at latest compatible version
discourse-user-notes is already at latest compatible version
discourse-whos-online is already at latest compatible version
discourse-yearly-review is already at latest compatible version
docker_manager is already at latest compatible version

I, [2023-09-23T12:57:22.787693 #1]  INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    too many connection resets (Gem::RemoteFetcher::FetchError)
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request.rb:250:in `rescue in perform_request'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request.rb:194:in `perform_request'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request.rb:155:in `fetch'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:310:in `request'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:210:in `fetch_http'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:249:in `fetch_path'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:286:in `cache_update_path'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:157:in `rescue in download'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/remote_fetcher.rb:142:in `download'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/source.rb:208:in `download'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/resolver/specification.rb:113:in `download'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/resolver/specification.rb:99:in `install'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request_set.rb:280:in `block in install_into'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request_set.rb:272:in `each'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request_set.rb:272:in `install_into'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/request_set.rb:148:in `install'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/commands/install_command.rb:215:in `install_gem'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/commands/install_command.rb:231:in `block in install_gems'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/commands/install_command.rb:224:in `each'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/commands/install_command.rb:224:in `install_gems'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/commands/install_command.rb:170:in `execute'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command.rb:328:in `invoke_with_build_args'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:253:in `invoke_command'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:193:in `process_args'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:151:in `run'
        /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:52:in `run'
        /usr/local/bin/gem:12:in `<main>'
I, [2023-09-23T13:23:20.135088 #1]  INFO -- : gem install tokenizers -v 0.3.3 -i /var/www/discourse/plugins/discourse-ai/gems/3.2.2 --no-document --ignore-dependencies --no-user-install

You are specifying the gem tokenizers in /var/www/discourse/plugins/discourse-ai/plugin.rb, however it does not exist!
Looked for:
- /var/www/discourse/plugins/discourse-ai/gems/3.2.2/specifications/tokenizers-0.3.3.gemspec
- /var/www/discourse/plugins/discourse-ai/gems/3.2.2/specifications/tokenizers-0.3.3-x86_64-linux.gemspec
- /var/www/discourse/plugins/discourse-ai/gems/3.2.2/specifications/tokenizers-0.3.3-x86_64-linux.gemspec

I, [2023-09-23T13:23:20.135292 #1]  INFO -- : Terminating async processes
I, [2023-09-23T13:23:20.135305 #1]  INFO -- : Sending INT to HOME=/var/lib/postgresql USER=postgres exec chpst -u postgres:postgres:ssl-cert -U postgres:postgres:ssl-cert /usr/lib/postgresql/13/bin/postmaster -D /etc/postgresql/13/main pid: 41
I, [2023-09-23T13:23:20.135317 #1]  INFO -- : Sending TERM to exec chpst -u redis -U redis /usr/bin/redis-server /etc/redis/redis.conf pid: 110
110:signal-handler (1695475400) Received SIGTERM scheduling shutdown...
2023-09-23 13:23:20.135 UTC [41] LOG:  received fast shutdown request
2023-09-23 13:23:20.152 UTC [41] LOG:  aborting any active transactions
2023-09-23 13:23:20.154 UTC [41] LOG:  background worker "logical replication launcher" (PID 50) exited with exit code 1
2023-09-23 13:23:20.155 UTC [45] LOG:  shutting down
2023-09-23 13:23:20.198 UTC [41] LOG:  database system is shut down
110:M 23 Sep 2023 13:23:20.223 # User requested shutdown...
110:M 23 Sep 2023 13:23:20.223 * Saving the final RDB snapshot before exiting.
110:M 23 Sep 2023 13:23:20.286 * DB saved on disk
110:M 23 Sep 2023 13:23:20.286 # Redis is now ready to exit, bye bye...

Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1163 exit 255>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}
bootstrap failed with exit code 255
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
1 Like

That’s not related to this plugin.

This plugin installs fine. I rebuilt with it only this morning.

1 Like

Can you help me with the proper way to do the edit in? I haven’t found anything related to AI and “language” keyword.

1 Like

I’m trying to change the language in which the summary is written. I have a Spanish website but the summaries are in English.