Class CompositeResponseTextCleaner

java.lang.Object
org.springframework.ai.converter.CompositeResponseTextCleaner
All Implemented Interfaces:
ResponseTextCleaner

public class CompositeResponseTextCleaner extends Object implements ResponseTextCleaner
A composite ResponseTextCleaner that applies multiple cleaners in sequence. This allows for a flexible pipeline of text cleaning operations.
Since:
1.1.0
Author:
liugddx
  • Constructor Details

    • CompositeResponseTextCleaner

      public CompositeResponseTextCleaner(List<ResponseTextCleaner> cleaners)
      Creates a composite cleaner with the given cleaners.
      Parameters:
      cleaners - the list of cleaners to apply in order
    • CompositeResponseTextCleaner

      public CompositeResponseTextCleaner()
      Creates a composite cleaner with no cleaners. Text will be returned unchanged.
    • CompositeResponseTextCleaner

      public CompositeResponseTextCleaner(ResponseTextCleaner... cleaners)
      Creates a composite cleaner with the given cleaners.
      Parameters:
      cleaners - the cleaners to apply in order
  • Method Details

    • clean

      public String clean(String text)
      Description copied from interface: ResponseTextCleaner
      Clean the given text by removing unwanted patterns, tags, or formatting.
      Specified by:
      clean in interface ResponseTextCleaner
      Parameters:
      text - the raw text from LLM response
      Returns:
      the cleaned text ready for parsing
    • builder

      public static CompositeResponseTextCleaner.Builder builder()
      Creates a builder for constructing a composite cleaner.
      Returns:
      a new builder instance