ahvn.adapter.vdb module¶

class ahvn.adapter.vdb.VdbUKFAdapter(backend=None, *args, **kwargs)[source]¶

Bases: BaseUKFAdapter

Vector database adapter that provides logical conversion between UKF objects and vector database records.

This adapter creates field type mappings dynamically based on the included fields and provides conversion methods between UKF objects and LlamaIndex TextNode objects. Does not handle any physical connection operations - those are managed by VectorDatabase.

virtual_fields = ('id', 'expiration_timestamp')¶
__init__(backend=None, *args, **kwargs)[source]¶

Initialize the vector adapter with specified field inclusion.

Parameters:
  • name – Name of the adapter instance.

  • include – List of BaseUKF field names to include in the vector database schema. If None, includes all available BaseUKF fields plus virtual fields. The ‘id’ field is always included automatically.

  • exclude – List of BaseUKF field names to exclude from the vector database schema. If None, excludes no fields.

  • backend – Vector database backend (‘lancedb’, ‘chroma’, ‘milvuslite’, etc.). Used for backend-aware type conversions.

  • *args – Additional positional arguments.

  • **kwargs – Additional configuration parameters.

Returns:

None

parse_id(key)[source]¶
Parameters:

key (int)

from_ukf(kl, key=None, embedding=None)[source]¶

Convert a BaseUKF object to a LlamaIndex TextNode.

Parameters:
  • kl (BaseUKF) – BaseUKF object to convert.

  • key (Optional[str]) – Optional text content for the TextNode. If None, uses kl.name.

  • embedding (Optional[List[float]]) – Optional vector embedding for the TextNode. If None, no embedding is set.

Return type:

TextNode

Returns:

LlamaIndex TextNode object representing the UKF data.

to_ukf_data(entity)[source]¶

Convert a vector database entity to a dictionary suitable for BaseUKF initialization.

Parameters:

entity (Dict[str, Any]) – Dictionary representing the vector database entity.

Return type:

Dict[str, Any]

Returns:

A dictionary of field names and values for BaseUKF initialization.

from_result(result)[source]¶

Convert a query result from the vector database to the appropriate representation.

Parameters:

result (Any) – The raw result from a vector database query.

Return type:

Any

Returns:

The converted representation.