Welcome to the Gemini workshop for Java developers, using the LangChain4j LLM orchestration framework.
This workshop is geared towards Java developers, to discover the Gemini Large Language Model created by Google. We will explore the model through the use of LangChain4j to interact with the LLM.
The steps and instructions in this workshop are detailed in the Gemini for Java Developers codelab.
In this workshop, you will be able to go through the following examples:
- Simple Question & Answer
- Simple Question & Answer via streaming
- Hold a conversation with a chatbot
- Describing an image with multimodality (text+image)
- Extracting structured data from unstructured text
- Manipulating prompt templates
- Text classification & sentiment analysis
- Retrieval Augmented Generation
- Function calling
Before running the examples, you'll need to set up two environment variables:
export PROJECT_ID=YOUR_PROJECT_ID
export LOCATION=us-central1
Warning
Be sure to update the project ID and location to match your project.
Use the Gradle wrapper to run the examples:
./gradlew run -DjavaMainClass=gemini.workshop.QA
./gradlew run -DjavaMainClass=gemini.workshop.StreamQA
./gradlew run -DjavaMainClass=gemini.workshop.Conversation
./gradlew run -DjavaMainClass=gemini.workshop.Multimodal
./gradlew run -DjavaMainClass=gemini.workshop.ExtractData
./gradlew run -DjavaMainClass=gemini.workshop.PromptTemplate
./gradlew run -DjavaMainClass=gemini.workshop.TextClassification
./gradlew run -DjavaMainClass=gemini.workshop.RAG
./gradlew run -DjavaMainClass=gemini.workshop.FunctionCalling
The code examples have been tested on the following environment:
- Java 21
- Gradle 8.6
In order to run these examples, you need to have a Google Cloud account and project ready.
This is not an official Google product.