Thanks for the pointer to the table implementation. Not sure the table approach scales, though. For N topics, we need a table of size N^2. so for 10^4 topics the table would have 10^8 entries.
I don’t see how to escape needing a python call to parse a new topic, embed it, and find the nearest neighbors. I have in the past built a web interface, but I would probably be tempted here to just run a python process on the side and communicate with discourse through a socket or pipe, looking more or less like read and write to a file rather than an actual python call. (It’s all running on my server, after all…)