You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The Mapping stage is an auxiliar component but is required by the Generative AI stage since its purpose is to map values from the intermediate and final, using jsonpath-ng · PyPI, into keywords that are going to be stored in an object in the intermediate.

Properties

PropertyDescriptionDefaultTypeRequired
mapping_configA configuration map of properties to extract from the results.-Union[string, None]No

Mapping_config example

mapping_config={
	"KEYWORD": f"jsonpath.format.for.intermediate.and.final.objects"
	"CONTENT": f"$.{SEARCH_STAGE_NAME}.hits[*].data.overview",
    "QUESTION": f"$.q",
    "MOVIE_URL": f"$.{SEARCH_STAGE_NAME}.hits[*].data.url",
    "MOVIE_TITLE": f"$.{SEARCH_STAGE_NAME}.hits[*].data.title",
    "MOVIE_RELEASE_DATE": f"$.{SEARCH_STAGE_NAME}.hits[*].data.release_date"
}

Intermediate Parameters

This stage does not require any specific intermediate parameters, nevertheless, you can use any value in the intermediate or final objects as long as it matches the jsonpath pattern provided.

Remember that the intermediate can be fill with either other stages or the original request body that trigger the pipeline, making this essentially REST API parameters.

Example Configuration

_search_mapping = MappingStage(
    type='MappingStage',
    name="VectorSearchMapping",
    mapping_config={
        "CONTENT": f"$.{SEARCH_STAGE_NAME}.hits[*].data.overview",
        "QUESTION": f"$.q",
        "MOVIE_URL": f"$.{SEARCH_STAGE_NAME}.hits[*].data.url",
        "MOVIE_TITLE": f"$.{SEARCH_STAGE_NAME}.hits[*].data.title",
        "MOVIE_RELEASE_DATE": f"$.{SEARCH_STAGE_NAME}.hits[*].data.release_date"
    }
)
  • No labels