Skip to content

[codex] Migrate Android to LiteRT-LM and refresh Gemma 4 example#9

Open
riderx wants to merge 8 commits into
mainfrom
codex/migrate-litertlm-gemma4-example
Open

[codex] Migrate Android to LiteRT-LM and refresh Gemma 4 example#9
riderx wants to merge 8 commits into
mainfrom
codex/migrate-litertlm-gemma4-example

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Apr 16, 2026

What

  • migrate the Android backend to LiteRT-LM for .litertlm models while keeping a MediaPipe fallback for legacy .task files
  • refresh the README and TypeScript docs around the new Android model flow
  • update the example app to showcase Gemma 4 LiteRT-LM downloads on Android and keep Apple Intelligence as the iOS default
  • fix the stale example unit test so it matches the current LLM home screen

Why

  • MediaPipe LLM Inference is deprecated on Android and iOS, and Android now has an official LiteRT-LM path
  • the repo examples were still centered on old Gemma 3 placeholder URLs and .task expectations
  • keeping the legacy Android fallback avoids breaking existing consumers while moving new integrations onto LiteRT-LM

How

  • added com.google.ai.edge.litertlm:litertlm-android:0.10.0 and rewrote the Android model loader/chat flow to route .litertlm models through LiteRT-LM conversations
  • preserved legacy Android .task handling through the existing MediaPipe path so old assets still load
  • tightened Android plugin error handling so invalid chat/model state rejects synchronously instead of resolving and failing later
  • rewrote the docs and example app model picker around real Gemma 4 E2B/E4B LiteRT-LM downloads from litert-community
  • split the long iOS sendMessage implementation into helpers so the repo lint gate stays green
  • prepared with Codex

Testing

  • bun run lint
  • bun run check:wiring
  • bun run verify
  • cd example-app && bun install && bun run build
  • cd example-app && bun run test:unit -- --run

Not Tested

  • end-to-end inference on physical iOS or Android devices with a downloaded Gemma 4 model
  • PR CI and automated review comments after opening this PR

Summary by CodeRabbit

  • New Features

    • Clarified platform defaults (iOS Apple Intelligence, Android LiteRT‑LM preference, Web MediaPipe) and added a generationError event/listener.
  • Bug Fixes

    • Improved readiness states, unified streaming/error propagation, and more robust generation-error reporting.
  • Documentation

    • Streamlined README and example-app docs with concise model-setup examples and updated platform guidance.
  • Refactor

    • Consolidated backend selection, model-loading and streaming flows; simplified example app UI and model catalog.
  • Tests

    • Updated HomePage unit test expectations.
  • Chores

    • Added Android runtime support for the LiteRT‑LM model flow and updated package keywords.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds dual-backend LLM support and platform defaults: iOS defaults to Apple Intelligence (optional MediaPipe), Android prefers LiteRT‑LM (.litertlm) with legacy MediaPipe (.task) fallback, and Web remains MediaPipe-based. Implements backend selection, model loading/resolution, streaming/error event emission, docs/examples updates, and adds LiteRT dependency.

Changes

Cohort / File(s) Summary
Repository docs & examples
README.md, example-app/README.md, example-app/...
Rewrote platform/model strategy and simplified install/model-setup examples; removed large per-platform setup sections and pointed to example-app/README.md; updated usage snippets and added generationError docs.
Android core & plugin
android/src/main/java/ee/forgr/capgo_llm/LLM.java, android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java
Added backend selection (LiteRT vs MediaPipe) by modelType/extension; changed setModel signature to accept modelType and randomSeed; added asset resolution/copying, LiteRT Engine/Conversation lifecycle, MediaPipe LlmInference path, stricter IllegalStateException semantics, and emits generationError events instead of direct call rejects.
Android build
android/build.gradle
Added LiteRT‑LM runtime dependency: com.google.ai.edge.litertlm:litertlm-android:0.10.0.
iOS plugin implementation
ios/Sources/LLMPlugin/LLMPlugin.swift
Refactored Apple Intelligence and MediaPipe streaming into helpers (streamAppleResponse, streamMediaPipeResponse, extractAppleTextChunk); added availability validation and safer optional handling.
Type definitions & web
src/definitions.ts, src/web.ts
Added exported GenerationErrorEvent and addListener('generationError', ...) overload; updated JSDoc for platform/model expectations; web sendMessage now tracks streamed state and notifies generationError when partial output was emitted and an error occurs.
Example app UI & tests
example-app/src/views/HomePage.vue, example-app/tests/unit/example.spec.ts
UI: computed canSendMessage/inputPlaceholder, empty initial conversation, updated model catalog favoring Gemma 4 LiteRT entries, setConversationIntro, readiness-state refinements, and generationError handler; unit test expectation text updated.
Package metadata
package.json
Added keywords: gemma4, litert, litert-lm.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Example App\n(HomePage.vue)
    participant Plugin as LLMPlugin\n(Capacitor)
    participant Backend as Backend\nSelector
    participant LiteRT as LiteRT\nEngine
    participant MediaPipe as MediaPipe\nInference
    participant Model as Model\nFile

    User->>UI: Select model & send message
    UI->>Plugin: setModel(path, modelType, options)
    Plugin->>Backend: Determine backend by modelType/extension

    alt modelType == 'litertlm'
        Backend->>Model: Resolve .litertlm path (/android_asset/... or download)
        Backend->>LiteRT: Initialize Engine & Conversation
        LiteRT-->>Backend: Engine ready
    else modelType == 'task' or iOS system model
        Backend->>Model: Resolve .task or system model
        Backend->>MediaPipe: Initialize LlmInference
        MediaPipe-->>Backend: Inference ready
    end

    Backend-->>Plugin: onModelLoaded()
    Plugin-->>UI: notify readiness

    User->>UI: sendMessage(chatId, text)
    UI->>Plugin: sendMessage(chatId, text)

    alt Using LiteRT
        Plugin->>LiteRT: conversation.sendMessageAsync()
        LiteRT-->>Plugin: streamed chunk events
        Plugin-->>UI: streaming updates (aiFinished with chatId)
    else Using MediaPipe
        Plugin->>MediaPipe: Run inference with prompt/history
        MediaPipe-->>Plugin: stream/final text
        Plugin-->>UI: streaming updates or final message
    end

    Plugin->>UI: emit generationError on failure (with chatId if partial output)
    UI-->>User: display response or error
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Two paths, one carrot bright,
I hop between Litert and Apple light,
MediaPipe hums its steady song,
I nibble bugs and stream along,
Hooray — the chat finishes strong.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main changes: migrating Android to LiteRT-LM and updating the Gemma 4 example, which align with the core objectives and file modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/migrate-litertlm-gemma4-example

Comment @coderabbitai help to get the list of available commands and usage tips.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Apr 16, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedprettier-pretty-check@​0.2.07310010086100
Addedswiftlint@​2.0.0901007983100
Addedprettier-plugin-java@​2.8.110010010089100
Addedtypescript@​5.9.3100100909990
Addedprettier@​3.8.3901009797100

View full report

@riderx riderx marked this pull request as ready for review April 16, 2026 10:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bdc17f5d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
android/src/main/java/ee/forgr/capgo_llm/LLM.java (1)

330-401: ⚠️ Potential issue | 🟠 Major

Close LlmInferenceSession on the error path too.

inferenceSession.close() only runs in the done branch. If anything throws after createFromOptions() succeeds but before completion, the catch exits without releasing the native session.

🛠️ Suggested fix
-                com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession inferenceSession =
-                    com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession.createFromOptions(llmInference, sessionOptions);
-
-                inferenceSession.addQueryChunk(fullPrompt);
+                com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession inferenceSession = null;
+                inferenceSession =
+                    com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession.createFromOptions(llmInference, sessionOptions);
+
+                inferenceSession.addQueryChunk(fullPrompt);
@@
-            } catch (Exception exception) {
-                callback.onError(exception.getMessage());
+            } catch (Exception exception) {
+                try {
+                    if (inferenceSession != null) {
+                        inferenceSession.close();
+                    }
+                } catch (Exception closeException) {
+                    android.util.Log.e("LLM", "Failed to close MediaPipe session", closeException);
+                }
+                callback.onError(exception.getMessage());
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java` around lines 330 - 401,
The LlmInferenceSession created by
com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession.createFromOptions
(stored in inferenceSession) is only closed in the done branch, so if an
exception occurs after creation the native session leaks; ensure
inferenceSession is closed on the error path by tracking the created
inferenceSession reference and calling inferenceSession.close() from the catch
(or better, a finally) block while null-checking it and swallowing or logging
any close exceptions (reference symbols: createFromOptions, inferenceSession,
generateResponseAsync, resultListener).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java`:
- Around line 63-95: setModel currently stores request parameters on instance
fields (modelPath, modelType, maxTokens, topk, temperature, randomSeed), calls
resetModelState(), then calls initializeModel which queues work that reads those
mutable fields allowing race between rapid setModel calls; to fix,
capture/snapshot all request parameters into a local immutable request object
(or final local variables) inside setModel and pass that snapshot into
initializeModel (e.g., initializeModel(requestSnapshot, callback)), add a
monotonic load/version token (e.g., long loadId) on the instance that you
increment in setModel and include in the snapshot, and then have initializeModel
and its queued/completion logic verify the loadId matches the instance's current
loadId before committing state or invoking the callback so out-of-order tasks
are discarded.
- Around line 316-321: sendMessageWithMediaPipe creates a new
LlmInferenceSession per send but calls session.buildPrompt(message) which only
returns the latest user text, so prior turns in session.history never reach the
model; fix by constructing the full prompt from the accumulated session history
(e.g., use session.getHistory() or change session.buildPrompt to include
history) and pass that full prompt into the LlmInferenceSession invocation (or
reuse the existing LlmInferenceSession instead of creating a fresh one) so the
model sees prior turns and the .task fallback preserves context.

In `@example-app/src/views/HomePage.vue`:
- Around line 484-488: Currently the UI state (selectedModel.value,
chatId.value, setConversationIntro) is changed before the model is actually
ready; instead, perform downloadModel(), setModel(), and initializeChat() first
inside a try/catch and only update selectedModel.value, chatId.value and call
setConversationIntro(...) after those succeed; on failure restore the previous
selectedModel (capture previousSelected = selectedModel.value), do not clear
chatId or change intro, and surface the error (e.g., via showToast/log) so the
usable conversation isn’t lost and the failed model isn’t shown as selected.
- Around line 87-95: The send button in HomePage.vue is icon-only (ion-button
with ion-icon using sendIcon) and needs an accessible name so screen readers
announce its purpose; add an explicit label by setting an aria-label (e.g.,
"Send message") on the ion-button or include visually hidden text inside the
button, ensuring the existing bindings (`@click`="sendMessage",
:disabled="!canSendMessage", class="send-button") remain unchanged so behavior
and styling are preserved.

---

Outside diff comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java`:
- Around line 330-401: The LlmInferenceSession created by
com.google.mediapipe.tasks.genai.llminference.LlmInferenceSession.createFromOptions
(stored in inferenceSession) is only closed in the done branch, so if an
exception occurs after creation the native session leaks; ensure
inferenceSession is closed on the error path by tracking the created
inferenceSession reference and calling inferenceSession.close() from the catch
(or better, a finally) block while null-checking it and swallowing or logging
any close exceptions (reference symbols: createFromOptions, inferenceSession,
generateResponseAsync, resultListener).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4309c9c5-3bb9-47a8-bf92-a227c86400fe

📥 Commits

Reviewing files that changed from the base of the PR and between 23f06d6 and 3bdc17f.

📒 Files selected for processing (10)
  • README.md
  • android/build.gradle
  • android/src/main/java/ee/forgr/capgo_llm/LLM.java
  • android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java
  • example-app/README.md
  • example-app/src/views/HomePage.vue
  • example-app/tests/unit/example.spec.ts
  • ios/Sources/LLMPlugin/LLMPlugin.swift
  • package.json
  • src/definitions.ts

Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java
Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java Outdated
Comment thread example-app/src/views/HomePage.vue
Comment thread example-app/src/views/HomePage.vue Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java (1)

104-116: ⚠️ Potential issue | 🟡 Minor

Align Android’s implicit randomSeed with the other platforms.

Android now starts honoring randomSeed, but the fallback here is 101 while src/web.ts uses 0. That makes omitted randomSeed values behave differently by platform, which is surprising now that the examples do not set it explicitly.

Suggested fix
-        Integer randomSeed = call.getInt("randomSeed", 101);
+        Integer randomSeed = call.getInt("randomSeed", 0);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java` around lines 104 -
116, The Android code uses call.getInt("randomSeed", 101) which defaults
randomSeed to 101 and causes platform divergence; change the default to 0 so the
local variable randomSeed and the llm.setModel(...) invocation use 0 when
omitted (matching src/web.ts). Update the getInt call for "randomSeed" to use 0
as the fallback so llm.setModel(path, modelType, maxTokens, topk, temperature,
randomSeed, ...) behaves consistently across platforms.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 372-379: The generated README table marks fields like modelType,
randomSeed, companionUrl, filename, and GenerationErrorEvent.chatId as required
even though they are optional in src/definitions.ts; update the JSDoc/docgen
source so optional properties are emitted as optional (e.g., use the JSDoc
optional syntax with square brackets or the `@property` optional marker in the
typedefs in src/definitions.ts or adjust the docgen config that transforms JSDoc
into markdown) so the generated markdown tables preserve optionality for those
symbols (modelType, randomSeed, companionUrl, filename,
GenerationErrorEvent.chatId).

In `@src/web.ts`:
- Around line 74-80: The catch block currently both emits
notifyListeners('generationError', ...) and rethrows the error, causing web
callers to receive duplicate failure signals; in the method that contains this
block (e.g., sendMessage / the response-generation path), remove the rethrow and
return early after calling notifyListeners('generationError', ...) so post-start
generation failures are only surfaced via the generationError event (ensure the
function returns the appropriate void/Promise resolution consistent with its
signature instead of throwing).

---

Outside diff comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java`:
- Around line 104-116: The Android code uses call.getInt("randomSeed", 101)
which defaults randomSeed to 101 and causes platform divergence; change the
default to 0 so the local variable randomSeed and the llm.setModel(...)
invocation use 0 when omitted (matching src/web.ts). Update the getInt call for
"randomSeed" to use 0 as the fallback so llm.setModel(path, modelType,
maxTokens, topk, temperature, randomSeed, ...) behaves consistently across
platforms.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8a07369-1671-4904-afa3-782f8243c122

📥 Commits

Reviewing files that changed from the base of the PR and between 3bdc17f and fb2004d.

📒 Files selected for processing (6)
  • README.md
  • android/src/main/java/ee/forgr/capgo_llm/LLMPlugin.java
  • example-app/src/views/HomePage.vue
  • ios/Sources/LLMPlugin/LLMPlugin.swift
  • src/definitions.ts
  • src/web.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • ios/Sources/LLMPlugin/LLMPlugin.swift
  • src/definitions.ts
  • example-app/src/views/HomePage.vue

Comment thread README.md Outdated
Comment thread src/web.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java`:
- Around line 35-45: Multiple threads read/write shared fields (isReady,
activeBackend, engine, llmInference, modelPath, modelType, currentLoadId) and
the chatSessions map while only applyLoadedModel() is synchronized, causing data
races; fix by making shared state access thread-safe: replace HashMap
chatSessions with a ConcurrentHashMap, mark simple status fields (isReady,
activeBackend, modelPath, modelType, currentLoadId) as volatile, and guard
compound operations and mutations (applyLoadedModel(), resetModelState(),
createChat(), sendMessage(), and any methods referenced around lines 270-292 and
308-328) with a single ReentrantReadWriteLock (use readLock for reads in
createChat()/sendMessage() and writeLock for mutations in
applyLoadedModel()/resetModelState()), ensuring engine and llmInference are read
under the lock or published safely to avoid races.
- Around line 138-141: When a load is superseded after calling
initializeMediaPipeModel, explicitly close the created LlmInference instance
before dropping it and ensure resetModelState() also closes and clears the
llmInference field; update the block after initializeMediaPipeModel(actualPath,
request) (and the notifySupersededLoad path) to call llmInference.close() or
loadedInference.close() if not null when a supersede is detected (use the same
close pattern used for LlmInferenceSession), and modify resetModelState() to
safely close llmInference and set it to null to avoid native resource leaks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7854fb8b-f7e8-4251-b05f-cd5322f5cd54

📥 Commits

Reviewing files that changed from the base of the PR and between fb2004d and 713b34e.

📒 Files selected for processing (2)
  • android/src/main/java/ee/forgr/capgo_llm/LLM.java
  • example-app/src/views/HomePage.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • example-app/src/views/HomePage.vue

Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java
Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
android/src/main/java/ee/forgr/capgo_llm/LLM.java (1)

253-269: Consider skipping asset copy if destination already exists.

The method copies the asset unconditionally. For repeated model loads with the same asset path, checking if the destination file exists could avoid redundant I/O.

Proposed optimization
 private void copyAssetToFile(String assetPath, File destination) throws Exception {
+    if (destination.exists()) {
+        return;
+    }
+
     File parent = destination.getParentFile();
     if (parent != null && !parent.exists()) {
         parent.mkdirs();
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java` around lines 253 - 269,
The copyAssetToFile method currently always copies the asset; modify it to first
check if the destination file already exists (destination.exists()) and return
early if present to avoid redundant I/O. Keep the existing parent directory
creation logic (parent.mkdirs()) but add the existence check before opening the
asset stream; if you need stronger validation, compare file length or checksum
of destination vs. asset (using context.getAssets().open(assetPath).available()
or a quick checksum) and only perform the copy when sizes/checks differ. Ensure
this change is applied inside the copyAssetToFile method.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java`:
- Around line 190-202: In initializeLiteRtModel replace the incorrect
EngineConfig positional call that supplies three Backend.CPU() and uses
maxTokens with a call matching LiteRT-LM 0.10.0: construct EngineConfig with
modelPath, a single Backend (new Backend.CPU()), the cache directory string
(context.getCacheDir().getAbsolutePath()), and explicit nulls for visionBackend
and audioBackend (or supply appropriate backends if used), and ensure any
maxTokens usage is renamed/removed to match the library’s maxNumTokens API;
update the EngineConfig invocation in LLM.initializeLiteRtModel and any related
variables to match the com.google.ai.edge.litertlm 0.10.0 constructor signature.

---

Nitpick comments:
In `@android/src/main/java/ee/forgr/capgo_llm/LLM.java`:
- Around line 253-269: The copyAssetToFile method currently always copies the
asset; modify it to first check if the destination file already exists
(destination.exists()) and return early if present to avoid redundant I/O. Keep
the existing parent directory creation logic (parent.mkdirs()) but add the
existence check before opening the asset stream; if you need stronger
validation, compare file length or checksum of destination vs. asset (using
context.getAssets().open(assetPath).available() or a quick checksum) and only
perform the copy when sizes/checks differ. Ensure this change is applied inside
the copyAssetToFile method.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: acb3b933-ac7e-4b0b-9cfd-a55bf6290534

📥 Commits

Reviewing files that changed from the base of the PR and between bbe3c14 and 72e933f.

📒 Files selected for processing (1)
  • android/src/main/java/ee/forgr/capgo_llm/LLM.java

Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e28f85f366

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread android/src/main/java/ee/forgr/capgo_llm/LLM.java Outdated
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.

1 participant