Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bae3e51

Browse files
committedMay 19, 2024
Add getContent() method to ChatResponse
1 parent 6f4ab64 commit bae3e51

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎spring-ai-core/src/main/java/org/springframework/ai/chat/ChatResponse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ public Generation getResult() {
7878
return this.generations.get(0);
7979
}
8080

81+
/**
82+
* Convenience method equivalent to {@code getResult().getOutput().getContent()}.
83+
* @return The content from the output of the first {@link Generation} in the
84+
* generations list.
85+
*/
86+
public String getContent() {
87+
return getResult().getOutput().getContent();
88+
}
89+
8190
/**
8291
* @return Returns {@link ChatResponseMetadata} containing information about the use
8392
* of the AI provider's API.

0 commit comments

Comments
 (0)
Please sign in to comment.