There are two types of retrievers: table and volume. Given the different nature of the data sources, and the options required for each we have different functions to register them.
Retriever for a table data source
The aidb.register_retriever_for_table function is used to create a retriever for a table data source. This is the function signature, you can see many of those are optional and have defaults.
If you are using external data sources, you need to create a volume and register a retriever for it, which is explained in the next section.
Retriever for a volume data source
Creating a new volume
Before we can register a retriever for a volume, we need to create a volume. The aidb.create_volume function is used to create a volume. This is the function signature, you can see many of those are optional and have defaults.
Note that mime_type actually takes only Text or Image as values.
Example: Creating a volume
The server_name comes from calling PGFS functions to create a storage location; pgfs.create_storage_location. The path is the path to the data in the storage location.
Registering a retriever for a volume
The aidb.register_retriever_for_volume function is used to create a retriever for a volume data source. This is the function signature, you can see many of those are optional and have defaults.
Example: Registering a retriever for a volume
In this example, we use all the defaults.
Creating the Embeddings
You can use bulk embedding if there is existing data in the source table:
Enable auto-embedding for any future changes:
You can disable auto-embedding as well:
Retrieving
A basic key retriever, aidb.retrieve_key is available that does not look up the source data, but just returns the ID/key of the matching embeddings:
Retrieving the key
Example: Retrieving the key
This can be used if you want to do a join/lookup yourself based on the key. For retrievers with external (volume) data sources, this is especially useful. Usually the application itself wants to do the retrieval from the external data source. Or you might want to push-down the actual retrieval to a client application.
The retrieve_text function joins the embeddings with the source data and directly returns the results:
Retrieving the text
The retrieve_text function joins the embeddings with the source data and directly returns the results:
Example
Listing the retrievers
A view is available that lists all the retrievers. aidb.retrievers also includes some of the retrievers configuration:
It is recommended that you just select the columns you are interested in:
Deleting a retriever
This will not delete the vector table or anything else, just the configuration:
End to end example
You can find an end-to-end example for a table/text retriever at on the Retrievers example page.