public static String formatPromptBookKeywords()

in sessions/next24/books-genai-vertex-springai/src/main/java/services/utility/PromptUtility.java [32:48]


    public static String formatPromptBookKeywords(List<String> keywords) {
        // Check for an empty topics list
        List<String> params = keywords.stream()
                .filter(Objects::nonNull)  // Filters out null values
                .filter(p -> p instanceof String && !((String) p).isEmpty()) // Filters out empty strings
                .collect(Collectors.toList());

        if (params==null || params.isEmpty()) {
            return "Find the paragraphs mentioning any topic in the book."; // Or other default message
        }

        // Join the topics with commas
        String joinedTopics = String.join(", ", params);

        // Use String.format to insert the joined topics into the prompt
        return String.format("Find the paragraphs mentioning keywords in the following list: {%s} in the book.", joinedTopics);
    }