Class BasePromptTemplate

java.lang.Object
com.hw.langchain.prompts.base.BasePromptTemplate
Direct Known Subclasses:
BaseChatPromptTemplate, StringPromptTemplate

public abstract class BasePromptTemplate extends Object
Base class for all prompt templates, returning a prompt.
Author:
HamaWhite
  • Field Details

    • inputVariables

      protected List<String> inputVariables
      A list of the names of the variables the prompt template expects.
    • outputParser

      protected BaseOutputParser<?> outputParser
      How to parse the output of calling an LLM on this formatted prompt.
    • partialVariables

      protected Map<String,Object> partialVariables
  • Constructor Details

    • BasePromptTemplate

      protected BasePromptTemplate(List<String> inputVariables)
    • BasePromptTemplate

      protected BasePromptTemplate(List<String> inputVariables, Map<String,Object> partialVariables)
    • BasePromptTemplate

      protected BasePromptTemplate(List<String> inputVariables, BaseOutputParser<?> outputParser)
  • Method Details

    • formatPrompt

      public abstract PromptValue formatPrompt(Map<String,Object> kwargs)
      Create Chat Messages.
    • mergePartialAndUserVariables

      public Map<String,Object> mergePartialAndUserVariables(Map<String,Object> kwargs)
      Merge the partial variables and user variables into a single map.
      Parameters:
      kwargs - Additional user variables provided.
      Returns:
      Merged map containing partial variables and user variables.
    • format

      public abstract String format(Map<String,Object> kwargs)
      Format the prompt with the inputs.
      Parameters:
      kwargs - Any arguments to be passed to the prompt template.
      Returns:
      A formatted string.