Class FormatUtils

java.lang.Object
com.hw.langchain.prompts.utils.FormatUtils

public class FormatUtils extends Object
Author:
HamaWhite
  • Method Details

    • formatTemplate

      public static String formatTemplate(String template, Map<String,Object> kwargs)
      Formats the given template string by replacing variables with corresponding values.
      Parameters:
      template - the template string to format
      kwargs - a map of variables and their corresponding values
      Returns:
      the formatted string
    • findVariables

      public static List<String> findVariables(String input)
      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