Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description

I'm trying to render a prompt template which contains variables that use key-1 as a variable name. Exception is thrown while rendering my prompt template. Below is the stacktrace:

1:14: invalid character '-'
1:14: invalid character '1'

java.lang.IllegalStateException: Not all template variables were replaced. Missing variable names are [key]

    at org.springframework.ai.chat.prompt.PromptTemplate.validate(PromptTemplate.java:221)
    at org.springframework.ai.chat.prompt.PromptTemplate.render(PromptTemplate.java:124)

Environment

Spring AI 1.0.0-SNAPSHOT Java 17

Steps to reproduce Steps to reproduce the issue.

The bug can be reproduced via the following unit test code:

@Test
public void testRenderWithHyphen() {
Map<String, Object> model = Map.of("key-1", "value1");
String template = "This is a {key-1}";
PromptTemplate promptTemplate = new PromptTemplate(template, model);

String expected = "This is a value1";
String result = promptTemplate.render();

assertEquals(expected, result);
}

Expected behavior

No exception thrown, the template can be rendered correctly.

Minimal Complete Reproducible example

Please see my example above.