lancedb_haystack.conversion.python_to_lancedb

Functions

convert_document_to_lancedb(→ dict)

Converts a Haystack Document to a format ready to store in lancedb

convert_field(value, field_type)

Converts the value of a field from it's representation in haystack to the one used for LanceDB

convert_struct(→ dict)

Convert a dict into the format expected by LanceDB

convert_timestamp(→ pyarrow.Scalar)

Convert datetime or iso string into the format expected by LanceDB.

Module Contents

lancedb_haystack.conversion.python_to_lancedb.convert_document_to_lancedb(document: haystack.Document, schema: pyarrow.Schema) dict

Converts a Haystack Document to a format ready to store in lancedb

Parameters:
  • document – the Haystack document to prepare for insertion into LanceDB

  • schema – the lancedb table schema

Returns:

a dict

lancedb_haystack.conversion.python_to_lancedb.convert_field(value: Any, field_type: pyarrow.DataType)

Converts the value of a field from it’s representation in haystack to the one used for LanceDB

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, so we know how to convert it.

Returns:

the converted value

lancedb_haystack.conversion.python_to_lancedb.convert_struct(value: dict, field_type: pyarrow.StructType) dict

Convert a dict into the format expected by LanceDB

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, so we know how to convert it.

Returns:

the converted value

lancedb_haystack.conversion.python_to_lancedb.convert_timestamp(value: datetime.datetime | str, field_type: pyarrow.DataType) pyarrow.Scalar

Convert datetime or iso string into the format expected by LanceDB.

Parameters:
  • value – the value to convert

  • field_type – The pyarrow type of the value, so we know how to convert it.

Returns:

the converted value