@@ -70,10 +70,11 @@ The format instructions are most often appended to the end of the user input usi
70
70
{format}
71
71
"""; // user input with a "format" placeholder.
72
72
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
+ );
77
78
----
78
79
79
80
The 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 = """
134
135
""";
135
136
136
137
Generation 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();
138
139
139
140
ActorsFilms actorsFilms = this.beanOutputConverter.convert(this.generation.getOutput().getText());
140
141
----
@@ -180,7 +181,7 @@ String template = """
180
181
{format}
181
182
""";
182
183
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();
184
185
185
186
Generation generation = chatModel.call(this.prompt).getResult();
186
187
@@ -212,8 +213,8 @@ String template = """
212
213
{format}
213
214
""";
214
215
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();
217
218
218
219
Generation generation = chatModel.call(this.prompt).getResult();
219
220
@@ -245,8 +246,7 @@ String template = """
245
246
{format}
246
247
""";
247
248
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();
250
250
251
251
Generation generation = this.chatModel.call(this.prompt).getResult();
252
252
0 commit comments