Commit Graph
18 Commits
Author SHA1 Message Date
Andrew Heard 555203f373 refactor(ai)!: remove legacy Foundation Models integration (#16693)
Clean up the interim integration with Apple's Foundation Models
framework in Firebase AI Logic for Firebase 13.

Apple now natively supports third-party providers in the Foundation
Models framework via LanguageModel, which is implemented directly by
GeminiLanguageModel. The custom GenerativeModelSession,
SystemLanguageModel, HybridModel, custom GenerationSchema, and related
bridging types and protocols are now obsolete.

- Remove GenerativeModelSession, SystemLanguageModel, HybridModel,
  GeminiModel, and related session protocols and provider types.
- Remove custom GenerationSchema, GeneratedContent, and related
  structured output protocols.
- Remove internal responseJSONSchema support from GenerationConfig and
  associated test permutations in FirebaseAILogic and TestApp.
- Remove IS_FOUNDATION_MODELS_SUPPORTED_PLATFORM build settings from
  Package.swift and FirebaseAILogic.podspec.

BREAKING CHANGE: GenerativeModelSession, SystemLanguageModel,
HybridModel, GeminiModel, and associated interim integration types and
protocols have been removed. Use GeminiLanguageModel with Apple's
Foundation Models framework instead.
2026-09-24 10:01:14 -04:00
Andrew Heard 97932016ef feat(ai): use VALIDATED function calling mode in GLM (#16649)
Default to VALIDATED function calling mode in GeminiLanguageModel and
switch guided generation to responseJsonSchema.
Previously, tool-calling requests mapped the default or allowed mode to
AUTO, which does not strictly enforce parameter schemas. Because Swift
decodes tool arguments strictly, schema malformation results in failed
turns. Additionally, guided generation used responseFormat, which the
Gemini backend ignores when VALIDATED mode is active during tool-calling
sessions, dropping response schemas and causing structured decoding
failures in respond(to:generating:).
* Default unset and explicit .allowed toolCallingMode to VALIDATED mode
  to strictly enforce schema adherence via constrained decoding.
* Throw LanguageModelError.unsupportedCapability on unrecognized future
  tool calling modes instead of silently falling back to allowed.
* Omit functionCallingConfig entirely when requests declare no functions
  to avoid contradictory constrained decoding states.
* Send responseJsonSchema with application/json MIME type for guided
  generation, which constrained decoding honors alongside VALIDATED.
* Remove unused _responseJsonSchema property from GenerationConfig.
* End SSE response streams and cancel tasks upon receiving terminal
  finish reasons or prompt feedback block reasons.
* Add integration test for combined tool calling and guided generation.
* Refresh cached App Check debug tokens proactively within TTL window.
2026-09-17 17:51:18 -04:00
Andrew Heard 27eaab3918 feat(ai): document and expose GeminiLanguageModel (#16631)
Remove the GEMINI_LANGUAGE_MODEL environment variable check in
Package.swift to unconditionally include GeminiLanguageModel targets
and dependencies on supported Swift 6.4+ toolchains.

Add DocC documentation comments for the GeminiLanguageModel integration
with Apple's Foundation Models framework.

Provide usage guidance, public preview warnings, and links to Apple's
LanguageModel protocol, LanguageModelSession, and DynamicProfile. In
addition, document FirebaseAI.geminiLanguageModel(name:) and include
a code example showing how to instantiate and use the model.
2026-09-09 15:57:01 -04:00
Andrew Heard a512638ecd refactor(ai): consolidate HTTP request headers (#16612) 2026-09-04 21:45:01 -04:00
Andrew Heard 3796a55fdf feat(ai): add GeminiLanguageModel (#16601)
Implemented `GeminiLanguageModel`, providing an adapter for Google's
Gemini models conforming to Apple's `FoundationModels.LanguageModel`
protocol. This PR includes text to text generation capabilities; other
modalities and Gemini features will be handled in follow-up PRs.

**Note:** The `GeminiLanguageModel` implementation is guarded by the
environment variable `GEMINI_LANGUAGE_MODEL`. By default none of the
`GeminiLanguageModel` implementation is included.

Key additions:
- `GeminiLanguageModel`: Implements `LanguageModel` protocol with
  reasoning capabilities, configuring execution via `ModelResource`
  and `EndpointConfiguration`.
- `GeminiLanguageModelExecutor`: Converts prompt instructions and
  history into Gemini streaming requests, yielding responses as
  `LanguageModelSession.ResponseStream`.
- `GeminiTranscriptTranslator`: Translates Apple `Transcript` entries
  and segments into Gemini `Content` structures while preserving thought
  signatures and validating supported transcript features.
- `GeminiLanguageModel.Error` and `GeminiErrorMapper`: Translates Gemini
  API, HTTP, and network errors into standard `LanguageModelError` cases
  (`rateLimited`, `timeout`, `guardrailViolation`, `refusal`, and
  `unsupportedLanguageOrLocale`) or `GeminiLanguageModel.Error` cases
  (`serviceUnavailable`, `networkFailure`, `modelNotFound`, `apiError`).
  The `APIError` payload is designed for seamless forward compatibility
  with both GenerateContent and the upcoming Interactions API.
- Testing infrastructure: Adds `ConditionTrait.requireFoundationModels`
  to conditionally run Foundation Models tests only on supported
  platforms (macOS 27+, iOS 27+, watchOS 27+, visionOS 27+), along with
  shared test constants, mock fixtures, and comprehensive unit and
  integration test suites.
2026-09-04 18:05:45 -04:00
Andrew Heard 56c1eef4ea chore(ci): add xcode 27 to spm test matrix (#16604) 2026-09-04 11:38:33 -04:00
Andrew Heard 57e4e51357 fix(ai): Handle Xcode 27 LanguageModelSession.Error collision (#16257) 2026-06-10 10:49:03 -04:00
Andrew Heard 67d2c5d0f2 [AI] Rename GeminiModel to GeminiLanguageModel (#16227) 2026-06-04 09:56:35 -04:00
Andrew Heard d47bc4e3d2 [AI] Use respond(to:options:) for String generation (#16165) 2026-05-12 22:31:44 -04:00
Andrew Heard 09298bd555 [AI] Add hybrid and Foundation Models debug logging (#16134) 2026-04-29 00:16:01 -04:00
Andrew Heard b1c9e27fd0 [AI] Add hybrid support with Foundation Models (#16111) 2026-04-23 23:45:36 -04:00
Andrew Heard adb6dd46a2 [AI] Add visionOS 26.0 to @available annotations (#16114) 2026-04-23 19:06:33 -04:00
Paul Beusterien 4ab415ebc9 [SPM] Fix unfound file warnings from swift build (#16041) 2026-04-10 13:48:42 -07:00
2a57f97341 [AI] Automatic function calling (#15915)
Co-authored-by: Paul Beusterien <paulbeusterien@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-31 23:48:34 -04:00
Andrew Heard 6e71c8c5b6 [AI] Add IS_FOUNDATION_MODELS_SUPPORTED_PLATFORM flag (#15999) 2026-03-30 17:16:27 -04:00
Daymon dad019eb9a chore(ai): Add additional logging support for live api server messages (#15940) 2026-03-20 12:08:28 -04:00
Andrew Heard 150698e98a [AI] Lower minimum required deployment targets (#15928) 2026-03-12 18:33:33 -04:00
4565e79f78 [AI] Add GenerativeModelSession with structured output APIs (#15872)
Co-authored-by: Paul Beusterien <paulbeusterien@google.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-10 00:51:04 -04:00