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
Modifier 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
ModifierConstructorDescriptionprotected
BasePromptTemplate
(List<String> inputVariables) protected
BasePromptTemplate
(List<String> inputVariables, BaseOutputParser<?> outputParser) protected
-
Method Summary
Modifier and TypeMethodDescriptionabstract String
Format the prompt with the inputs.abstract PromptValue
formatPrompt
(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.
-