Skip to content

Commit f3a132e

Browse files
authored
fix: GH-3713 Fixed outdated code examples in the documentation. (#3717)
Auto-cherry-pick to 1.0.x Fixes #3713 Signed-off-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com> Co-authored-by: Sun Yuhan <sunyuhan1998@users.noreply.github.com>
1 parent 15e1eaa commit f3a132e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/structured-output-converter.adoc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

7980
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 = """
134135
""";
135136
136137
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();
138139
139140
ActorsFilms 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
185186
Generation 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
218219
Generation 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
251251
Generation generation = this.chatModel.call(this.prompt).getResult();
252252

0 commit comments

Comments
 (0)