GEPA.Adapters.GenericRAG.VectorStore behaviour (GEPA v0.3.0)

Copy Markdown View Source

Behaviour for vector-store backends used by GEPA.Adapters.GenericRAG.

Documents are maps with at least :content/"content" and optional :metadata/"metadata". Search callbacks may return either a list directly or {:ok, list}/{:error, reason} when the backend performs external IO.

Summary

Types

document()

@type document() :: %{optional(String.t() | atom()) => term()}

filters()

@type filters() :: map() | nil

search_result()

@type search_result() :: [document()] | {:ok, [document()]} | {:error, term()}

Callbacks

create_collection(term, arg2)

(optional)
@callback create_collection(term(), keyword() | map()) :: :ok | {:error, term()}

delete_documents(term, list, arg3)

(optional)
@callback delete_documents(term(), [term()], keyword() | map()) :: :ok | {:error, term()}

embedding_dimension(term)

(optional)
@callback embedding_dimension(term()) :: pos_integer() | nil

get_collection_info(term)

@callback get_collection_info(term()) :: map()

health_check(term)

(optional)
@callback health_check(term()) :: :ok | {:error, term()}

reset_collection(term, arg2)

(optional)
@callback reset_collection(term(), keyword() | map()) :: :ok | {:error, term()}

similarity_search(term, t, pos_integer, filters)

@callback similarity_search(term(), String.t(), pos_integer(), filters()) ::
  search_result()

supports_hybrid_search?(term)

(optional)
@callback supports_hybrid_search?(term()) :: boolean()

supports_metadata_filtering?(term)

(optional)
@callback supports_metadata_filtering?(term()) :: boolean()

upsert_documents(term, list, arg3)

(optional)
@callback upsert_documents(term(), [document()], keyword() | map()) ::
  {:ok, [term()]} | {:error, term()}

vector_search(term, list, pos_integer, filters)

@callback vector_search(term(), [number()], pos_integer(), filters()) :: search_result()

Functions

create_collection(store, opts \\ [])

@spec create_collection(term(), keyword() | map()) :: :ok | {:error, term()}

delete_documents(store, ids, opts \\ [])

@spec delete_documents(term(), [term()], keyword() | map()) :: :ok | {:error, term()}

embedding_dimension(store)

@spec embedding_dimension(term()) :: pos_integer() | nil

get_collection_info(store)

@spec get_collection_info(term()) :: map()

health_check(store)

@spec health_check(term()) :: :ok | {:error, term()}

hybrid_search(store, query, k \\ 5, alpha \\ 0.5)

@spec hybrid_search(term(), String.t(), pos_integer(), float()) :: search_result()

Perform a hybrid search. Defaults to similarity search.

reset_collection(store, opts \\ [])

@spec reset_collection(term(), keyword() | map()) :: :ok | {:error, term()}

similarity_search(store, query, k \\ 5, filters \\ nil)

@spec similarity_search(term(), String.t(), pos_integer(), filters()) ::
  search_result()

supports_hybrid_search?(store)

@spec supports_hybrid_search?(term()) :: boolean()

supports_metadata_filtering?(store)

@spec supports_metadata_filtering?(term()) :: boolean()

upsert_documents(store, documents, opts \\ [])

@spec upsert_documents(term(), [document()], keyword() | map()) ::
  {:ok, [term()]} | {:error, term()}

vector_search(store, query_vector, k \\ 5, filters \\ nil)

@spec vector_search(term(), [number()], pos_integer(), filters()) :: search_result()