In the past couple months I’ve been testing nextcloud’s AI capabilities, with the latest being context chat.
I had a rough time hosting its backend on arm, but I made it work.
I’m using Nextcloud AIO, which provides Elasticsearch out of the box for full text search.
AFAIK Elasticsearch supports vector embeddings since version 8.7 (May 2023), while context chat started development around Sep 2023.
I understand the separation of responsibilities logic, but it’s a huge waste of resources double indexing files in 2 separate databases.
Moreover; context_chat_backend is hardcoded to use its own embeddings engine (and model), even though nextcloud might have an active OpenAI integration. In my fork I added support for remote embeddings API, sadly with environment variables as there’s no OCS endpoint for embeddings or reading integration_openai’s configuration.
Things like these give me the impression that Nextcloud dev teams work too separately, or even that some features sacrifice good practices over fast development (although if you used Elasticsearch and OpenAI from the get-go context_chat would take like 20% of the effort currently put into it).
Backwards compatible suggestions
- Create an OCS endpoint for embeddings *
- Remove the
CPU|GPUoption from the app_api daemon **, it’s high time ExApps got their own configuration options in the Nextcloud GUI via a/settingsendpoint ***. - Now that
context_chat_backendcan have configurable options ****, the user can:
a. Select the embeddings engine (CPU / GPU / OpenAI)
b. Select a custom embeddings model
c. Select a vector database (Elasticsearch if it’s available, or pgvector) - If Elasticsearch is used as a vector database
context_chatshould not send files tocontext_chat_backendfor indexing, but it should enable vector embeddings in Elasticsearch and trigger an embeddings generation for already indexed files (by adding an ingest pipeline ?)
* This shall be used by Elasticsearch when using it as a vector database, or context_chat_backend when using pgvector.
** Really useful for multi-model backends.
*** Having easy configurable options will enable more ExApps getting created in general.
**** context_chat_backend (or any ExApp) must handle restarting itself if needed for the new configuration to apply
P.S. OpenAI => OpenAI compatible API, not necessarily the OpenAI API. I found Koboldcpp easier to host than LocalAI (especially on new Macs).