Package com.hw.langchain.prompts.base
Class BasePromptTemplate
java.lang.Object
com.hw.langchain.prompts.base.BasePromptTemplate
- Direct Known Subclasses:
BaseChatPromptTemplate,StringPromptTemplate
Base class for all prompt templates, returning a prompt.
- Author:
- HamaWhite
-
Field Summary
FieldsModifier and TypeFieldDescriptionA list of the names of the variables the prompt template expects.protected BaseOutputParser<?>How to parse the output of calling an LLM on this formatted prompt. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBasePromptTemplate(List<String> inputVariables) protectedBasePromptTemplate(List<String> inputVariables, BaseOutputParser<?> outputParser) protected -
Method Summary
Modifier and TypeMethodDescriptionabstract StringFormat the prompt with the inputs.abstract PromptValueformatPrompt(Map<String, Object> kwargs) Create Chat Messages.mergePartialAndUserVariables(Map<String, Object> kwargs) Merge the partial variables and user variables into a single map.
-
Field Details
-
inputVariables
A list of the names of the variables the prompt template expects. -
outputParser
How to parse the output of calling an LLM on this formatted prompt. -
partialVariables
-
-
Constructor Details
-
BasePromptTemplate
-
BasePromptTemplate
-
BasePromptTemplate
-
-
Method Details
-
formatPrompt
Create Chat Messages. -
mergePartialAndUserVariables
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
Format the prompt with the inputs.- Parameters:
kwargs- Any arguments to be passed to the prompt template.- Returns:
- A formatted string.
-