I think you could just remove those keys from the metadata if they are
None
π€
Not a full example, but the API is super simple:
https://gpt-index.readthedocs.io/en/latest/how_to/query_engine/advanced/second_stage.html#api-interfaceExample (note that in 0.6.34+,
extra_info
changed to
metadata
, but I'll use the old name here)
class MetadataPostprocessor:
"""Metadata Node postprocessor."""
def postprocess_nodes(
self, nodes: List[NodeWithScore], query_bundle: Optional[QueryBundle]
) -> List[NodeWithScore]:
"""Postprocess nodes."""
for n in nodes:
metadata = n.node.extra_info
if metadata and 'name' in metadata and metadata['name'] is None:
del n.node.extra_info['name']
return nodes