Pipelines retrievers (deprecated) reference
===========================================

..  Important::
   The use of the term "retrievers" has been deprecated in version 4.0 and later. It is replaced by the term "knowledge base" and users should consult the  :ref:`Pipelines knowledge bases reference <Pipelines knowledge bases reference>`  reference content.  For backwards compatibility, the retrievers API is still available, but it is recommended to use the knowledge base API for new implementations. This section is covers the deprecated functions only. For the new API, see  :ref:`Pipelines knowledge bases reference <Pipelines knowledge bases reference>`  .

aidb.RetrieverSourceDataFormat
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

No longer available. Use :ref:`aidb.PipelineDataFormat <aidb.PipelineDataFormat>`  instead.

Functions
---------

``aidb.create_retriever_for_table`` (deprecated)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Replaced by** :ref:`aidb.create_table_knowledge_base <aidb.create_table_knowledge_base>` 

Creates a retriever for a given table.

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  name,TEXT,Required,Name of the retriever
  model_name,TEXT,Required,Name of the model to use
  source_table,regclass,Required,Name of the table to use as source
  source_data_column,TEXT,Required,Column name in source table to use
  source_data_type,:ref:`aidb.PipelineDataFormat<aidb.PipelineDataFormat>` ,Required,"Type of data in that column (""Text"".""Image"",""PDF"")"
  source_key_column,TEXT,'id',Column to use as key to reference the rows
  vector_table,TEXT,NULL,""
  vector_data_column,TEXT,'embeddings',""
  vector_key_column,TEXT,'id',""
  topk,INTEGER,1,""
  distance_operator,:ref:`aidb.DistanceOperator<aidb.DistanceOperator>` ,'L2',""
  options,JSONB,'{}'::JSONB,Options
  index_type,TEXT,'vector',Type of index to use for the vector table.

..  note "Index_types"::
   - If `index_type`  is set to `vector` , the system will automatically create a  `hnsw <https://github.com/pgvector/pgvector?tab=readme-ov-file#hnsw>`_  index on the vector table based on the distance operator used in the retriever. This is the default index type. The `vector`  index type is only able to support 2000 dimensions or less. If more dimensions are needed, the index type should be set to `disabled` .

.. csv-table::
  :header: distance_operator,index_type
  :widths: 10,30
  :align: left
  :class: longtable

  L2,`vector_l2_ops`
  InnerProduct,`vector_ip_ops`
  Cosine,`vector_cosine_ops`
  L1,`vector_l1_ops`

- If ``index_type`` is set to ``ivfflat`` , the system will create a
  `IVFFlat <https://github.com/pgvector/pgvector?tab=readme-ov-file#ivfflat>`_  index on the vector table.

- If ``index_type`` is set to ``disabled`` , no index will be created.

.. ::
   #### Example

.. code:: sql

   SELECT aidb.create_retriever_for_table(
                  name => test_retriever,
                  model_name => simple_model,
                  source_table => test_source_table,
                  source_data_column => content,
                  source_data_type => Text,
          );

``aidb.create_retriever_for_volume`` (deprecated)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Replaced by** :ref:`aidb.create_volume_knowledge_base <aidb.create_volume_knowledge_base>` 

Creates a retriever for a given PGFS volume.

.. _parameters-1:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  name,TEXT,Required,Name of the retriever
  model_name,TEXT,Required,Name of the model
  source_volume_name,TEXT,Required,Name of the volume
  vector_table,TEXT,NULL,Name of the vector table
  vector_data_column,TEXT,'embeddings',Name of the vector column
  vector_key_column,TEXT,'id',Name of the key column
  topk,INTEGER,1,Number of results to return
  distance_operator,aidb.distanceoperator,'L2',Distance operator
  options,JSONB,'{}'::JSONB,Options
  index_type,TEXT,'vector',Type of index to use for the vector table.

..  note "Index_types"::
   - If `index_type`  is set to `vector` , the system will automatically create a  `hnsw <https://github.com/pgvector/pgvector?tab=readme-ov-file#hnsw>`_  index on the vector table based on the distance operator used in the retriever. This is the default index type. The `vector`  index type is only able to support 2000 dimensions or less. If more dimensions are needed, the index type should be set to `disabled` .

.. csv-table::
  :header: distance_operator,index_type
  :widths: 10,30
  :align: left
  :class: longtable

  L2,`vector_l2_ops`
  InnerProduct,`vector_ip_ops`
  Cosine,`vector_cosine_ops`
  L1,`vector_l1_ops`

- If ``index_type`` is set to ``ivfflat`` , the system will create a
  `IVFFlat <https://github.com/pgvector/pgvector?tab=readme-ov-file#ivfflat>`_  index on the vector table.

- If ``index_type`` is set to ``disabled`` , no index will be created.

.. ::
   #### Example

.. code:: sql

   SELECT aidb.create_retriever_for_volume(
                  name => demo_vol_retriever,
                  model_name => simple_model,
                  source_volume_name => demo_bucket_vol
          );

``aidb.set_retriever_auto_processing`` (deprecated)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Replaced by** :ref:`aidb.set_auto_knowledge_base <aidb.set_auto_knowledge_base>` 

Sets the auto-processing mode for this knowledge base.

.. _parameters-2:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  retriever_name,TEXT,"",Name of retriever for which to enable auto-embedding
  mode,aidb.PipelineAutoProcessingMode,"",Desired auto-processing mode

Example
^^^^^^^

.. code:: sql

   SELECT aidb.set_retriever_auto_processing(test_retriever, Live);
   SELECT aidb.set_retriever_auto_processing(test_retriever, Disabled);

``aidb.delete_retriever`` (deprecated)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**Replaced by** :ref:``aidb.delete_knowledge_base` <`aidb.delete_knowledge_base`>` 

Deletes only the retriever’s configuration from the database.

.. _parameters-3:

Parameters
^^^^^^^^^^

.. csv-table::
  :header: Parameter,Type,Default,Description
  :widths: 15,12,12,20
  :align: left
  :class: longtable

  retriever_name,TEXT,"",Name of retriever to delete

.. _example-1:

Example
^^^^^^^

.. code:: sql

   select aidb.delete_retriever(test_retriever);
   __OUTPUT__
    delete_retriever
   - -----------------

   (1 row)
