/*
 * Copyright 2024 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package gemini.workshop;

import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.vertexai.VertexAiGeminiChatModel;
import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.ImageContent;
import dev.langchain4j.data.message.TextContent;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.output.Response;

public class Step3_Multimodal {

    static final String CAT_IMAGE_URL = 
        "https://upload.wikimedia.org/wikipedia/commons/e/e9/" + 
        "Felis_silvestris_silvestris_small_gradual_decrease_of_quality.png";

    public static void main(String[] args) {
        ChatLanguageModel model = VertexAiGeminiChatModel.builder()
            .project(System.getenv("PROJECT_ID"))
            .location(System.getenv("LOCATION"))
            .modelName("gemini-1.0-pro-vision")
            .build();

        UserMessage userMessage = UserMessage.from(
            ImageContent.from(CAT_IMAGE_URL),
            TextContent.from("Describe the picture")
        );

        Response<AiMessage> response = model.generate(userMessage);

        System.out.println(response.content().text());
    }
}

dev.langchain4j.model.vertexai.VertexAiGeminiChatModel.builder
[((1277, 1478), 'dev.langchain4j.model.vertexai.VertexAiGeminiChatModel.builder'), ((1277, 1457), 'dev.langchain4j.model.vertexai.VertexAiGeminiChatModel.builder'), ((1277, 1409), 'dev.langchain4j.model.vertexai.VertexAiGeminiChatModel.builder'), ((1277, 1360), 'dev.langchain4j.model.vertexai.VertexAiGeminiChatModel.builder')]