Skip to content

Gemini workshop for Java developers, using the Spring AI orchestration framework

License

Notifications You must be signed in to change notification settings

ddobrin/gemini-workshop-for-spring-ai-java-developers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini in Java with Vertex AI and Spring AI

Gemini workshop for Java developers, using the Spring AI orchestration framework

Note

This is the code for Gemini in Java with Vertex AI and Spring AI codelab geared towards Java developers to discover Gemini and its open-source variant Gemma Large Language Model by Google using Spring AI framework.

Prerequisites

The code examples have been tested on the following environment:

  • Java 21
  • Maven >= 3.9.6

In order to run these examples, you need to have a Google Cloud account and project ready.

Before running the examples, you'll need to set up three environment variables:

export VERTEX_AI_GEMINI_PROJECT_ID=<your-project-id>
export VERTEX_AI_GEMINI_LOCATION=us-central1
export VERTEX_AI_GEMINI_MODEL=gemini-1.5-pro-001

# Note: you can test in another region or using the gemini-1.5-flash-001 model

Important

Please update the project ID and location to match your project and select the model of your choice

Create the Maven wrapper:

mvn wrapper:wrapper

Codelab Samples

The samples in this codelab are grouped by various capabilities and patterns. You will find, in order:

  • Chat
    • Simple Q&A with Gemini
    • Conversation with Gemini with chat history
    • Simple Q&A via streaming
  • Multimodality
    • Analyzing & extracting image data using Multimodality
    • Transcribing audio data using Multimodality
    • Transcribing video data using Multimodality
  • Capabilities
    • Structure prompts with prompt templates
    • Extracting structured data from unstructured text
    • Grounding responses with Web Search
    • Function Calling with Spring AI
  • Document utilities
    • Document Readers and Splitters
  • Embeddings
    • Generating Text Embeddings with Vertex AI
    • Generating Multimodal Embeddings with Vertex AI
  • AI use-cases and patterns
    • Retrieval-augmented generation(RAG)
    • Text classification with Few-shot prompting
    • Sentiment analysis with few-shot prompting
    • Summarization Patterns with Gemini: Stuffing, Map-Reduce Patterns
  • Local environments
    • Running Open-models with Ollama and Testcontainers

Build

Tip

Note the profiles complete used for the build

Build the samples in a single JAR, then run them individually for the respective use-case:

./mvnw clean package -Pcomplete

Run

Tip

List of samples, by use-case. Each sample can be run independently


This is not an official Google product.

About

Gemini workshop for Java developers, using the Spring AI orchestration framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published