Class ArgumentsRewriteNoteTemplates
java.lang.Object
dev.langchain4j.internal.ArgumentsRewriteNoteTemplates
Renders and checks the template of the arguments rewrite note of
ToolInputGuardrailsConfig: the one place
that knows the names of its variables.- Since:
- 1.25.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic PromptTemplateensureValid(PromptTemplate template) Checks that the template renders with the variables of the note, and that the text it renders contains the result of the tool, so that a bad template fails before a tool runs rather than after it.static UnaryOperator<String> render(PromptTemplate template, String changedArguments) Renders the note, once: the date and time variables of the template keep their value for every result the note is put into.
-
Method Details
-
render
Renders the note, once: the date and time variables of the template keep their value for every result the note is put into. The variables are filled in one pass, so{{arguments}}or{{result}}in the arguments or in the result stay as they are. The text may be empty: a template with no text of its own around{{result}}gives the text of the result as is, also when it is empty.- Parameters:
template- the template of the notechangedArguments- the changed arguments, as a JSON object- Returns:
- the function that gives the text the LLM gets for the text of a result of the tool
-
ensureValid
Checks that the template renders with the variables of the note, and that the text it renders contains the result of the tool, so that a bad template fails before a tool runs rather than after it.- Parameters:
template- the template to check- Returns:
- the template
- Throws:
IllegalArgumentException- if the template isnull, uses a variable other than{{arguments}},{{result}}and the date and time variables ofPromptTemplate, cannot be rendered, or leaves out{{result}}
-