Package org.springframework.ai.converter
Class CompositeResponseTextCleaner
java.lang.Object
org.springframework.ai.converter.CompositeResponseTextCleaner
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreates a composite cleaner with no cleaners.CompositeResponseTextCleaner(List<ResponseTextCleaner> cleaners) Creates a composite cleaner with the given cleaners.CompositeResponseTextCleaner(ResponseTextCleaner... cleaners) Creates a composite cleaner with the given cleaners. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder for constructing a composite cleaner.Clean the given text by removing unwanted patterns, tags, or formatting.
-
Constructor Details
-
CompositeResponseTextCleaner
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
Creates a composite cleaner with the given cleaners.- Parameters:
cleaners- the cleaners to apply in order
-
-
Method Details
-
clean
Description copied from interface:ResponseTextCleanerClean the given text by removing unwanted patterns, tags, or formatting.- Specified by:
cleanin interfaceResponseTextCleaner- Parameters:
text- the raw text from LLM response- Returns:
- the cleaned text ready for parsing
-
builder
Creates a builder for constructing a composite cleaner.- Returns:
- a new builder instance
-