Class KeywordMetadataEnricher

java.lang.Object
org.springframework.ai.model.transformer.KeywordMetadataEnricher
All Implemented Interfaces:
Function<List<org.springframework.ai.document.Document>,List<org.springframework.ai.document.Document>>, org.springframework.ai.document.DocumentTransformer

public class KeywordMetadataEnricher extends Object implements org.springframework.ai.document.DocumentTransformer
Keyword extractor that uses generative to extract 'excerpt_keywords' metadata field.
Author:
Christian Tzolov, YunKui Lu
  • Field Details

  • Constructor Details

    • KeywordMetadataEnricher

      public KeywordMetadataEnricher(ChatModel chatModel, int keywordCount)
      Create a new KeywordMetadataEnricher instance.
      Parameters:
      chatModel - the model predictor to use for keyword extraction.
      keywordCount - the number of keywords to extract.
    • KeywordMetadataEnricher

      public KeywordMetadataEnricher(ChatModel chatModel, PromptTemplate keywordsTemplate)
      Create a new KeywordMetadataEnricher instance.
      Parameters:
      chatModel - the model predictor to use for keyword extraction.
      keywordsTemplate - the prompt template to use for keyword extraction.
  • Method Details

    • apply

      public List<org.springframework.ai.document.Document> apply(List<org.springframework.ai.document.Document> documents)
      Specified by:
      apply in interface Function<List<org.springframework.ai.document.Document>,List<org.springframework.ai.document.Document>>
    • builder

      public static KeywordMetadataEnricher.Builder builder(ChatModel chatModel)