feat(ai): add GeminiLanguageModel tool calling - #16620
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
d330410 to
cd30fb2
Compare
1086768 to
3658758
Compare
0170896 to
5672bfb
Compare
9685c3a to
d6109de
Compare
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.
Update documentation across GeminiLanguageModel test directories to cover tool calling (function calling) test suites and workflows. * Streamline Quick Start to use 'swift test --filter IntegrationTests', relying on .requireIntegrationTestingBackend for automatic execution or clean skipping. * Add 'swift test --filter ToolCallingIntegrationTests' and 'swift test --skip Integration' across test and test-server guides. * Update the test suites summary table to reflect tool calling in unit and integration test suites. * Add ToolCallingIntegrationTests.swift to the integration test file catalog. * Fix broken relative link to test_server documentation in IntegrationTests/README.md. * Format prose and remove extraneous blank lines.
Add integration tests for GeminiLanguageModel tool calling in FirebaseAI and streamline suite tagging. * Add testToolCalling and testToolCallingDisallowed integration tests for FirebaseAI.geminiLanguageModel in FirebaseAITestApp. * Define GetTemperature tool conforming to FoundationModels.Tool with @generable arguments and return types. * Move .tags(.integration) to the @suite declaration in ToolCallingIntegrationTests.swift.
d6109de to
e74e166
Compare
Add function calling (tool calling) support to
GeminiLanguageModelconforming to Apple's FoundationModels framework..toolCallingcapability toGeminiLanguageModel.ToolDefinitioninto a GeminiToolandFunctionDeclarationusingparametersJsonSchema.GenerationOptions.ToolCallingMode(.allowed,.required,.disallowed) to GeminiFunctionCallingConfig.Mode.GeminiLanguageModelExecutor, forwarding JSON-encoded arguments or empty fallback"{}"(omitted by the backend on empty arguments) into channel actions.Transcripttool calls and tool outputs into GeminiContentparts, preserving thought signatures from reasoning models and flushing buffered reasoning thoughts cleanly.GeminiLanguageModel,GeminiRequestTranslator, andGeminiTranscriptTranslator.#no-changelog