Commit Graph
7 Commits
Author SHA1 Message Date
Andrew Heard 6c78295b70 fix(ai): handle Transcript.Entry.data in GLM (#16890)
The Xcode 27.2 SDK (FoundationModels 2.1) adds a `Transcript.Entry.data`
case, which triggers a "switch must be exhaustive" warning in
`GeminiTranscriptTranslator`. Handle the new case by throwing
`unsupportedTranscriptContent`, gated with `canImport(FoundationModels,
_version: 2.1)` so only the one case is conditionally compiled and
Xcode 27.0 and 27.1 continue to build.

Add a unit test for the new case. It requires macOS 27.2 or later at
runtime, so it is skipped on earlier OS versions.

Add a `unit-tests` job to the GeminiLanguageModel workflow that runs
`swift test --skip IntegrationTests` on Xcode 27.0 and 27.2, as well as
on Xcode 26.6 (macOS 26) and Xcode 26.2 (macOS 15). The FoundationModels
code is compiled out on Xcode 26, so those jobs verify that the package
still builds and its remaining tests pass with older toolchains.

Update the test READMEs to use `--skip IntegrationTests`, since
`--skip Integration` also skips the `IntegrationTestingBackendTests`
unit tests.
2026-10-13 16:05:41 -04:00
Andrew Heard ead1af3543 refactor(ai): revert renaming to Gemini Enterprise API (#16846)
Revert commit dd2cfa8df1 (#16685) to undo
the renaming from Gemini Enterprise Agent Platform to Gemini Enterprise
API.

- Restore Backend.agentPlatform(location:) as the primary public API
  and remove Backend.enterprise(location:).
- Revert APIConfig.Service.enterprise to .agentPlatform and restore
  agentPlatformStagingBypassProxy.
- Revert documentation comments, DocC topics, and guides back to
  Agent Platform Gemini API and Gemini Enterprise Agent Platform.
- Clean up leftover Vertex AI symbols to align with Agent Platform and
  FirebaseAILogic (isFirebaseAILogicServiceDisabledError and
  defaultAgentPlatformAPIConfig).
- Re-align tests and conflict resolutions from #16689, #16693, #16676,
  and #16756.
2026-10-05 23:54:12 +00:00
Paul Beusterien dd2cfa8df1 docs(ai): deprecate agentPlatform in favor of enterprise (#16685) 2026-09-23 08:57:25 -07: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 7828d410ba feat(ai): add GeminiLanguageModel tool calling (#16620)
Add function calling (tool calling) support to GeminiLanguageModel
conforming to Apple's FoundationModels framework.

* Add .toolCalling capability to GeminiLanguageModel.
* Translate FoundationModels ToolDefinition into Gemini Tool and
  FunctionDeclaration using OpenAPI parametersJsonSchema.
* Map GenerationOptions.ToolCallingMode (.allowed, .required,
  .disallowed) to Gemini FunctionCallingConfig.Mode.
* Stream function calls in GeminiLanguageModelExecutor, forwarding
  JSON-encoded arguments or empty fallback "{}" into channel actions.
* Translate Transcript tool calls and tool outputs into Gemini Content
  parts, preserving thought signatures from reasoning models and
  flushing buffered reasoning thoughts cleanly.
* Unpack structured tool responses and wrap scalar text tool outputs
  under the result field.
* Support parameterless tools with empty arguments across request
  schema translation, model response handling, and transcript history.
* Add unit tests across GeminiLanguageModel, GeminiRequestTranslator,
  and GeminiTranscriptTranslator.
* Add end-to-end integration tests covering single-turn, sequential,
  parallel, disallowed, parameterless, and reasoning tool calling
  across all supported backends.
2026-09-08 18:19:18 -04:00
Andrew Heard b6dfaab8b9 feat(ai): add GeminiLanguageModel guided generation support (#16619)
Add guided generation (structured output) support to
GeminiLanguageModel conforming to Apple's LanguageModel.

* Extend GenerationSchema to translate schemas into Gemini-compatible
  JSON Schema definitions, remapping x-order to propertyOrdering.
* Detect unsupported regex pattern guides during encoding and throw
  LanguageModelError.unsupportedGenerationGuide.
* Introduce GeminiRequestTranslator to map generation requests and
  schemas into GenerateContentRequest and GenerationConfig.
* Delegate request translation in GeminiLanguageModelExecutor to
  GeminiRequestTranslator.
* Declare the .guidedGeneration capability on GeminiLanguageModel.
* Add comprehensive unit tests covering property ordering, nested
  definitions, enums, recursive schemas, and error throwing.
* Add parameterized integration tests for single-turn and streaming
  structured output generation, enum classification, and recursive
  hierarchies.
2026-09-08 12:01:29 -04:00
Andrew Heard bfb2eaac29 test(ai): GeminiLanguageModel integration testing foundation (#16617)
Establishes the integration testing foundation and parameterized test
suites for `GeminiLanguageModel`, enabling fast local execution via
`swift test` and automated CI verification on iOS Simulator.

Key Changes:
- `IntegrationTestingBackend`: Defines canonical backend configurations
  (`.developerAPI`, `.firebaseAILogicDeveloperAPI`, and
  `.firebaseAILogicAgentPlatform`), dynamically resolving endpoints,
  model resource paths, and auth headers from available credentials.
- `IntegrationTestEnvironment`: Centralizes credential discovery
  (`GEMINI_API_KEY`, `GOOGLE_API_KEY`, and `FIREBASE_PLIST_PATH`) into
  an immutable, thread-safe configuration struct with cached process
  access to avoid redundant disk I/O.
- `AppCheckDebugClient`: Implements a lightweight client to exchange
  debug tokens for App Check tokens without Keychain dependencies,
  deduplicating token requests across test runs with an in-memory cache.
- Parameterized Tests: Adds `BasicContentGenerationIntegrationTests`
  running against all available backends, tagged with `@Tag.integration`
  and gated by condition traits to cleanly skip when credentials are
  missing.
- CI Workflow: Adds `.github/workflows/sdk.geminilanguagemodel.yml` to
  run integration tests against Firebase AI Logic on iOS Simulator
  using decrypted repo secrets.
2026-09-07 18:28:37 -04:00