This project demonstrates a simple implementation of the Vertex AI Gemini Chat model using Vaadin Flow. The application allows users to enter a prompt and receive a generated response from the AI model.
Ensure you have the following installed:
- Java Development Kit (JDK) 11 or later
- Maven
- Google Cloud SDK
-
Set Environment Variables:
- Create a
.env
file in the root directory of your project or set the environment variables directly in your terminal. - Add the following lines to the
.env
file (replace with your actual project ID and location):GOOGLE_CLOUD_PROJECT_ID=your-project-id GOOGLE_CLOUD_LOCATION=your-location GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/service-account-file.json
- Create a
-
Load Environment Variables:
- For MacOS/Linux, run the following command in your terminal to load the environment variables:
export $(cat .env | xargs)
- For MacOS/Linux, run the following command in your terminal to load the environment variables:
This is a standard Maven project. To run it from the command line:
- Build and Run:
./mvnw clean install ./mvnw spring-boot:run
- Import to IDE:
- You can also import the project to your IDE of choice as you would with any Maven project.
To create a production build:
- Build:
./mvnw clean package -Pproduction
- This will build a JAR file with all dependencies and front-end resources, ready to be deployed. The file can be found in the target folder after the build completes.
- Run
java -jar target/your-app-1.0-SNAPSHOT.jar
- GeminiView.java: The main view component where users can enter prompts and see responses.
- application.properties: Configuration file where you can set various properties like project ID and location.