Class MarkdownCodeBlockCleaner

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

public class MarkdownCodeBlockCleaner extends Object implements ResponseTextCleaner
A ResponseTextCleaner that removes markdown code block formatting from LLM responses. This cleaner handles:
  • ```json ... ```
  • ``` ... ```
Since:
1.1.0
Author:
liugddx
  • Constructor Details

    • MarkdownCodeBlockCleaner

      public MarkdownCodeBlockCleaner()
  • 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