Package com.hw.langchain.prompts.utils
Class FormatUtils
java.lang.Object
com.hw.langchain.prompts.utils.FormatUtils
- Author:
- HamaWhite
-
Method Summary
Modifier and TypeMethodDescriptionfindVariables
(String input) Finds all variables enclosed in curly braces '{' and '}' in the input string, excluding variables enclosed in double curly braces '{{' or more.static String
formatTemplate
(String template, Map<String, Object> kwargs) Formats the given template string by replacing variables with corresponding values.
-
Method Details
-
formatTemplate
Formats the given template string by replacing variables with corresponding values.- Parameters:
template
- the template string to formatkwargs
- a map of variables and their corresponding values- Returns:
- the formatted string
-
findVariables
Finds all variables enclosed in curly braces '{' and '}' in the input string, excluding variables enclosed in double curly braces '{{' or more.- Parameters:
input
- the input string to search for variables- Returns:
- a list of variables found in the input string
-