@@ -70,10 +70,11 @@ The format instructions are most often appended to the end of the user input usi
7070 {format}
7171 """; // user input with a "format" placeholder.
7272 Prompt prompt = new Prompt(
73- new PromptTemplate(
74- this.userInputTemplate,
75- Map.of(..., "format", outputConverter.getFormat()) // replace the "format" placeholder with the converter's format.
76- ).createMessage());
73+ PromptTemplate.builder()
74+ .template(this.userInputTemplate)
75+ .variables(Map.of(..., "format", this.outputConverter.getFormat())) // replace the "format" placeholder with the converter's format.
76+ .build().createMessage()
77+ );
7778----
7879
7980The Converter<String, T> is responsible to transform output text from the model into instances of the specified type `T`.
@@ -134,7 +135,7 @@ String template = """
134135 """;
135136
136137Generation generation = chatModel.call(
137- new PromptTemplate( this.template, Map.of("actor", this.actor, "format", this.format)).create()).getResult();
138+ PromptTemplate.builder().template( this.template).variables( Map.of("actor", this.actor, "format", this.format)).build( ).create()).getResult();
138139
139140ActorsFilms actorsFilms = this.beanOutputConverter.convert(this.generation.getOutput().getText());
140141----
@@ -180,7 +181,7 @@ String template = """
180181 {format}
181182 """;
182183
183- Prompt prompt = new PromptTemplate( this.template, Map.of("format", this.format)).create();
184+ Prompt prompt = PromptTemplate.builder().template( this.template).variables( Map.of("format", this.format)).build( ).create();
184185
185186Generation generation = chatModel.call(this.prompt).getResult();
186187
@@ -212,8 +213,8 @@ String template = """
212213 {format}
213214 """;
214215
215- Prompt prompt = new PromptTemplate( this.template,
216- Map.of("subject", "an array of numbers from 1 to 9 under they key name 'numbers'", "format", this.format)).create();
216+ Prompt prompt = PromptTemplate.builder().template( this.template)
217+ .variables( Map.of("subject", "an array of numbers from 1 to 9 under they key name 'numbers'", "format", this.format)).build( ).create();
217218
218219Generation generation = chatModel.call(this.prompt).getResult();
219220
@@ -245,8 +246,7 @@ String template = """
245246 {format}
246247 """;
247248
248- Prompt prompt = new PromptTemplate(this.template,
249- Map.of("subject", "ice cream flavors", "format", this.format)).create();
249+ Prompt prompt = PromptTemplate.builder().template(this.template).variables(Map.of("subject", "ice cream flavors", "format", this.format)).build().create();
250250
251251Generation generation = this.chatModel.call(this.prompt).getResult();
252252
0 commit comments