Skip to content

Conversation

sunyuhan1998
Copy link
Contributor

As mentioned in the issue, TemplateRenderer currently only supports rendering templates. The ability to also parse and extract the required variables from a given template would be highly beneficial, especially for proactively validating template correctness. This PR implements that capability.

Specifically, it:

  1. Adds a getRequiredVariables method to TemplateRenderer to extract the variable names required by the template;

  2. Includes corresponding unit tests to ensure correctness and stability.

Fixes #4251

…TemplateRenderer` to parse the required variables from the template.

Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
# Conflicts:
#	spring-ai-model/src/test/java/org/springframework/ai/chat/prompt/SystemPromptTemplateTests.java
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TemplateRenderer should support retrieving required variables from the template.
1 participant