Skip to content

Added the MLKit Prompting API#1310

Merged
jonathanpeppers merged 8 commits into
mainfrom
dev/mlkit
Nov 6, 2025
Merged

Added the MLKit Prompting API#1310
jonathanpeppers merged 8 commits into
mainfrom
dev/mlkit

Conversation

@mattleibow

Copy link
Copy Markdown
Member

This pull request adds support for two new ML Kit GenAI libraries (genai-common and genai-prompt) to the project, including their configuration, API surface, and metadata transforms. The changes introduce the necessary NuGet package entries, public API definitions, and enum mappings to enable usage of Google's GenAI features in Xamarin. The most important changes are grouped below:

Configuration and Package Integration:

  • Added new entries for Xamarin.Google.MLKit.GenAI.Common and Xamarin.Google.MLKit.GenAI.Prompt to config.json, specifying their group IDs, artifact IDs, versions, NuGet IDs, and types.

Public API Exposure:

  • Introduced PublicAPI.Unshipped.txt files for both genai-common and genai-prompt, declaring all new types, methods, properties, and enums exposed by the GenAI libraries. This includes classes like AudioSource, BaseOptions, GenAiException, IGenerativeModel, GenerateContentRequest, and many more. [1] [2]
  • Enabled nullable reference types in the PublicAPI.Shipped.txt for both GenAI libraries to improve null safety and code clarity.

Enum and Metadata Mapping:

  • Added EnumFields.xml to map the GenAiErrorCode enum between CLR and JNI names/values for proper interop.
  • Added EnumMethods.xml to map methods that use the GenAiErrorCode enum in GenAiException.
  • Added Metadata.xml to remove unused internal classes and resolve naming conflicts for the GenAI exception error code interface.

@moljac

moljac commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

@mattleibow

========================================
verify-namespace-file
========================================
New Namespaces
--------------
Google.MLKit.GenAI.Common
Google.MLKit.GenAI.Common.Audio
Google.MLKit.GenAI.Prompt
Google.MLKit.GenAI.Prompt.Java

An error occurred when executing task 'verify-namespace-file'.

----------------------------------------
TearDown
----------------------------------------
     #TimingDataStopwatch,  20251104-052209.05,                   verify-namespace-file,         00:00:20.3795553
          #TimingDataCake,  20251104-052209.05,                   verify-namespace-file,         00:00:20.3787197
Error: Namespaces were added or removed.
please run:
    dotnet cake utilities.cake -t=generate-namespace-file

@mattleibow

Copy link
Copy Markdown
Member Author

@copilot please do what @moljac said and run

dotnet cake utilities.cake -t=generate-namespace-file

Copilot AI commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

@mattleibow I've opened a new pull request, #1313, to work on those changes. Once the pull request is ready, I'll request review from you.

@moljac

moljac commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

@mattleibow What powers do I need to become LLM Whisperer?

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@mattleibow

Copy link
Copy Markdown
Member Author

Not sure, i thiunk copilot is having issues because it did nothing.

@moljac

moljac commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

Not sure, i thiunk copilot is having issues because it did nothing.

Mental health?

Removed 'Google.MLKit.GenAI.Common.Internal' from the list.
@mattleibow
mattleibow requested review from Copilot and jonathanpeppers and removed request for Copilot November 5, 2025 02:05

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.

Pull Request Overview

This PR adds .NET bindings for two new Google ML Kit GenAI packages: com.google.mlkit:genai-common and com.google.mlkit:genai-prompt. These enable on-device generative AI capabilities in .NET for Android applications.

Key changes:

  • Added bindings for ML Kit GenAI Common (v1.0.0-beta2) and GenAI Prompt (v1.0.0-alpha1) libraries
  • Configured enum mappings for error codes and finish reasons
  • Applied metadata transforms to handle Kotlin-specific constructs and naming conventions
  • Registered new namespaces for the bindings

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
config.json Added two new artifact entries for genai-common and genai-prompt packages
source/com.google.mlkit/genai-common/Transforms/Metadata.xml Metadata transforms to remove Kotlin helpers, rename types, and clean up generated API
source/com.google.mlkit/genai-common/Transforms/EnumMethods.xml Maps GenAIException methods to use GenAIErrorCode enum type
source/com.google.mlkit/genai-common/Transforms/EnumFields.xml Defines GenAIErrorCode enum values from Java interface constants
source/com.google.mlkit/genai-common/PublicAPI/PublicAPI.Unshipped.txt Public API surface for genai-common package
source/com.google.mlkit/genai-common/PublicAPI/PublicAPI.Shipped.txt Placeholder for shipped API (empty)
source/com.google.mlkit/genai-prompt/Transforms/Metadata.xml Metadata transforms for prompt API including companion object handling
source/com.google.mlkit/genai-prompt/Transforms/EnumMethods.xml Maps Candidate.getFinishReason to use CandidateFinishReason enum
source/com.google.mlkit/genai-prompt/Transforms/EnumFields.xml Defines CandidateFinishReason enum values
source/com.google.mlkit/genai-prompt/PublicAPI/PublicAPI.Unshipped.txt Public API surface for genai-prompt package
source/com.google.mlkit/genai-prompt/PublicAPI/PublicAPI.Shipped.txt Placeholder for shipped API (empty)
published-namespaces.txt Added four new namespace entries for the GenAI bindings

Comment thread source/com.google.mlkit/genai-common/Transforms/Metadata.xml Outdated
Comment thread source/com.google.mlkit/genai-prompt/Transforms/Metadata.xml
mattleibow and others added 2 commits November 5, 2025 16:13
@jonathanpeppers
jonathanpeppers merged commit dcc1997 into main Nov 6, 2025
2 checks passed
@jonathanpeppers
jonathanpeppers deleted the dev/mlkit branch November 6, 2025 20:32
jonathanpeppers pushed a commit that referenced this pull request Nov 6, 2025
This pull request adds support for two new ML Kit GenAI libraries
(`genai-common` and `genai-prompt`) to the project, including their
configuration, API surface, and metadata transforms. The changes
introduce the necessary NuGet package entries, public API definitions,
and enum mappings to enable usage of Google's GenAI features in
Xamarin. The most important changes are grouped below:

**Configuration and Package Integration:**

* Added new entries for `Xamarin.Google.MLKit.GenAI.Common` and
  `Xamarin.Google.MLKit.GenAI.Prompt` to `config.json`, specifying
  their group IDs, artifact IDs, versions, NuGet IDs, and types.

**Public API Exposure:**

* Introduced `PublicAPI.Unshipped.txt` files for both `genai-common`
  and `genai-prompt`, declaring all new types, methods, properties,
  and enums exposed by the GenAI libraries. This includes classes like
  `AudioSource`, `BaseOptions`, `GenAiException`, `IGenerativeModel`,
  `GenerateContentRequest`, and many more.
  [[1]](diffhunk://#diff-2b143bb59f6a9252cb3498890690de011d8b139c1f4cd478fda23de9a2afe4ddR1-R93)
  [[2]](diffhunk://#diff-ef4ea7f0911b08ca9042afe31f3cf65a9c2c3ef3fbc298ac8931903c811ce4a4R1-R124)
* Enabled nullable reference types in the `PublicAPI.Shipped.txt` for
  both GenAI libraries to improve null safety and code clarity.

**Enum and Metadata Mapping:**

* Added `EnumFields.xml` to map the `GenAiErrorCode` enum between CLR
  and JNI names/values for proper interop.
* Added `EnumMethods.xml` to map methods that use the `GenAiErrorCode`
  enum in `GenAiException`.
* Added `Metadata.xml` to remove unused internal classes and resolve
  naming conflicts for the GenAI exception error code interface.
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.

5 participants