in sessions/next25/quotes-llm/src/main/java/com/example/quotes/domain/QuoteLLMService.java [30:55]
public Quote findRandomQuote() {
SystemMessage systemMessage = new SystemMessage("""
You are a helpful AI assistant.
You are an AI assistant that helps people find information.
You should reply to the user's request with your name and also in the style of a literary professor.
""");
UserMessage userMessage = new UserMessage("""
Answer precisely; please provide a quote from a random book,
including only book, quote and author; do not repeat quotes from the same book
return only 3 values, the book, the quote and the author, strictly in JSON format, wrapped in tripe backquotes ```json```, while eliminating every other text
""");
ChatResponse chatResponse = chatClient.call(new Prompt(List.of(systemMessage, userMessage),
VertexAiGeminiChatOptions.builder()
.temperature(0.4)
.model(env.getProperty(VERTEX_AI_GEMINI_MODEL))
.build())
);
Generation generation = chatResponse.getResult();
String input = generation.getOutput().getText();
System.out.printf("\nGemini Model provided response: \n%s\n", input);
return Quote.parseQuoteFromJson(input);
}