Skip to content

feat(gemini): Migrate to google-genai SDK and update dependencies - #805

Merged
haiphucnguyen merged 1 commit into
mainfrom
feature/fix-400-error-code-in-google-genai
Nov 5, 2026
Merged

haiphucnguyen merged 1 commit into
mainfrom
feature/fix-400-error-code-in-google-genai

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

⚠️ First-time contributor? This PR cannot be merged until you sign the CLA.
The CLA Assistant bot will post a comment below — reply to it with exactly:
I have read the CLA Document and I hereby sign the CLA
(Separate from this: all commits must also be signed off with git commit -s — see the Checklist.)

Summary

  • Upgrades core dependencies (Jackson, KotlinX, Jsoup, POI) to latest stable versions across the project.
  • Refactors Gemini model factory to use the modern GoogleGenAI client structure, resolving API deprecations.
  • Adds GeneratedImageHelper to centralize image generation logic within chat streams.
  • Increments project version to 1.5.5 to reflect dependency updates and fixes.

Related Issue(s)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • I signed the CLA (first-time contributors — reply to the CLA Assistant bot comment)
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

- Upgrades core dependencies (Jackson, KotlinX, Jsoup, POI) to latest stable versions across the project.
- Refactors Gemini model factory to use the modern GoogleGenAI client structure, resolving API deprecations.
- Adds `GeneratedImageHelper` to centralize image generation logic within chat streams.
- Increments project version to 1.5.5 to reflect dependency updates and fixes.
Copilot AI lite review requested due to automatic review settings November 5, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Active moderate issues remain in image extraction, custom endpoint propagation, executor cleanup, and request timeouts, including risks of silently dropped images, misrouted requests, resource leaks, and indefinite model creation blocking.

4 open issues
What changed in this PR

This pull request migrates the Gemini integration to LangChain4j’s Google GenAI SDK while updating dependencies, license metadata, third-party notices, and the project version.

Changes:

  • Replaces legacy Gemini chat, streaming, image, and embedding implementations.
  • Adds centralized generated-image extraction and updates streaming image handling.
  • Updates dependency versions, license allow-list entries, third-party notices, and version to 1.5.5.
File Description
THIRD-PARTY-NOTICES.txt Updates dependency versions, licenses, and transitive dependency notices.
shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​providers/​GeneratedImageHelper.kt Adds shared generated-image extraction and detection utilities.
shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​providers/​gemini/​GeminiModelFactory.kt Migrates Gemini model construction and thinking configuration to Google GenAI.
shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​providers/​ChatClientExtensions.kt Uses the generated-image helper during streaming responses.
gradle/​libs.versions.toml Updates dependency versions and replaces the Gemini integration artifact.
gradle/​allowed-licenses.json Allows licenses introduced by updated dependencies.
gradle.properties Increments the project version to 1.5.5.

This pull request requires changes.

Review effort: Lite

Comment on lines +23 to +38
fun getGeneratedImages(aiMessage: AiMessage?): MutableList<Image?> {
if (aiMessage?.attributes() == null) {
return mutableListOf()
}

val images = aiMessage.attributes().get(GENERATED_IMAGES_KEY)
if (images is MutableList<*>) {
return try {
images as MutableList<Image?>
} catch (e: ClassCastException) {
mutableListOf()
}
}

return mutableListOf()
}
Comment on lines +162 to +165
val executor = Executors.newVirtualThreadPerTaskExecutor()
val testModel = GoogleGenAiStreamingChatModel
.builder()
.httpClientBuilder(createJdkHttpClientBuilder())
.executor(executor)
val testModel = GoogleGenAiStreamingChatModel
.builder()
.httpClientBuilder(createJdkHttpClientBuilder())
.executor(executor)
Comment on lines +186 to 188
): ImageModel = GoogleGenAiImageModel.builder()
.apiKey(safeApiKey(settings.apiKey))
.httpClientBuilder(createJdkHttpClientBuilder())
.baseUrl(settings.baseUrl)
.modelName(settings.imageModel)
@haiphucnguyen
haiphucnguyen merged commit a7a7215 into main Nov 5, 2026
14 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/fix-400-error-code-in-google-genai branch November 6, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants