sessions/next24/books-genai-vertex-langchain4j/src/main/java/services/ai/VertexAIClient.java [111:136]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public String promptModelwithFunctionCalls(UserMessage userMessage,
                                               Object function) {
        long start = System.currentTimeMillis();

        ChatMemory chatMemory = MessageWindowChatMemory.withMaxMessages(10);

        ChatLanguageModel model = VertexAiGeminiChatModel.builder()
            .project(project)
            .location(location)
            .modelName(VertexModels.GEMINI_FLASH_VISION_VERSION)
            .build();

        Assistant assistant = AiServices.builder(Assistant.class)
            .chatLanguageModel(model)
            .chatMemory(chatMemory)
            .tools(function)
            .build();

        String output = assistant.chat(userMessage);

        logger.info("Elapsed time (gemini-pro, with Langchain4J): " + (System.currentTimeMillis() - start) + "ms");
        logger.info("Chat Model output with Function Call: " + output);

        // return model response in String format
        return output;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



sessions/fall24/books-genai-vertex-langchain4j/src/main/java/services/ai/VertexAIClient.java [111:136]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public String promptModelwithFunctionCalls(UserMessage userMessage,
                                               Object function) {
        long start = System.currentTimeMillis();

        ChatMemory chatMemory = MessageWindowChatMemory.withMaxMessages(10);

        ChatLanguageModel model = VertexAiGeminiChatModel.builder()
            .project(project)
            .location(location)
            .modelName(VertexModels.GEMINI_FLASH_VISION_VERSION)
            .build();

        Assistant assistant = AiServices.builder(Assistant.class)
            .chatLanguageModel(model)
            .chatMemory(chatMemory)
            .tools(function)
            .build();

        String output = assistant.chat(userMessage);

        logger.info("Elapsed time (gemini-pro, with Langchain4J): " + (System.currentTimeMillis() - start) + "ms");
        logger.info("Chat Model output with Function Call: " + output);

        // return model response in String format
        return output;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



