Skip to content

Commit 68adc26

Browse files
Mo-Greeneilayaperumalg
authored andcommitted
fix: Correct UserMessage example to use builder
The documentation example for UserMessage incorrectly used a private constructor. This commit updates the example to use the public `builder()` method, making the code functional. Signed-off-by: MoGreene <[email protected]>
1 parent 74eabfb commit 68adc26

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chat/google-genai-chat.adoc

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,10 @@ Below is a simple code example extracted from https://github.com/spring-projects
209209
----
210210
byte[] data = new ClassPathResource("/vertex-test.png").getContentAsByteArray();
211211
212-
var userMessage = new UserMessage("Explain what do you see on this picture?",
213-
List.of(new Media(MimeTypeUtils.IMAGE_PNG, this.data)));
212+
var userMessage = UserMessage.builder()
213+
.text("Explain what do you see o this picture?")
214+
.media(List.of(new Media(MimeTypeUtils.IMAGE_PNG, data)))
215+
.build();
214216
215217
ChatResponse response = chatModel.call(new Prompt(List.of(this.userMessage)));
216218
----
@@ -224,9 +226,10 @@ Use the `application/pdf` media type to attach a PDF file to the message:
224226
----
225227
var pdfData = new ClassPathResource("/spring-ai-reference-overview.pdf");
226228
227-
var userMessage = new UserMessage(
228-
"You are a very professional document summarization specialist. Please summarize the given document.",
229-
List.of(new Media(new MimeType("application", "pdf"), pdfData)));
229+
var userMessage = UserMessage.builder()
230+
.text("You are a very professional document summarization specialist. Please summarize the given document.")
231+
.media(List.of(new Media(new MimeType("application", "pdf"), pdfData)))
232+
.build();
230233
231234
var response = this.chatModel.call(new Prompt(List.of(userMessage)));
232235
----

0 commit comments

Comments
 (0)