Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Prompt Mapping stage is an auxiliar component but is required by the Generative AI stage Stage Prompt 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.

Table of Contents

Properties

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

Mapping_config example

Code Block
languagepy
themeDJango
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.

Tip

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

Code Block
languagepy
themeDJango
_search_mapping = MappingStagePromptMappingStage(
    type='MappingStage',
    name="VectorSearchMappingPromptMapping",
    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"
    }
)