The interface
The data shape
AnAi\Domain\ValueObjects\Embedding wraps a list of chunks, each an EmbeddingMap with the text and its vector:
search() returns a ranked list in the same shape the default store produces:
content values are what ends up in the model’s context, so return the text, not just IDs.
The search context
Implementation
src/AcmeVectors.php
Create collections lazily, on the first write, and make creation idempotent. Vector dimensions depend on the embedding model the installation uses, so read the dimension from the first vector you receive rather than hardcoding it.
Register it
src/Plugin.php
option.embeddings.adapter. If that key can’t be resolved, Aikeedo falls back to its built-in file store.
Settings page
Declare a route at/admin/settings/vector-databases/acme-vectors, and set extra.default_url to it. Useful fields: enable toggle, endpoint, API key, collection prefix, and a switch for per-assistant collections.
Operational notes
- Switching stores doesn’t migrate data. Existing knowledge bases must be re-indexed after a switch. Say so on your settings page.
- Deletes matter. When a document is removed,
remove()must delete its vectors, or answers will cite deleted content. - Fail soft on search. If the database is unreachable, returning an empty array degrades the answer. Throwing breaks the chat.
- Watch the payload size. Store the chunk text, since search results must return it.
Testing
Upload a document to a knowledge base and confirm vectors appear in your database.
Ask a question that the document answers, and check the answer cites it.
Re-upload the same document and confirm chunks are replaced, not duplicated.
Delete the document and confirm its vectors are gone.
Two knowledge bases don’t see each other’s content.