Skip to content

[AI] Add FirebaseAI.Instructions type with resultBuilder#16202

Draft
andrewheard wants to merge 5 commits into
mainfrom
ah/ai-instructions-resultbuilder
Draft

[AI] Add FirebaseAI.Instructions type with resultBuilder#16202
andrewheard wants to merge 5 commits into
mainfrom
ah/ai-instructions-resultbuilder

Conversation

@andrewheard
Copy link
Copy Markdown
Contributor

@andrewheard andrewheard commented May 26, 2026

Added a FirebaseAI.Instructions type with a Swift result builder. This enables trailing-closure syntax for specifying system instructions comprised of strings and structured data. For example:

let session = FirebaseAI.firebaseAI().generativeModelSession(
  model: .geminiModel(name: "gemini-3.5-flash")
) {
  "You are a weather bot that summarizes local weather conditions. Here is an example: "

  WeatherConditions(
    temperature: 25.0,
    conditions: "Sunny",
    summary: "A beautiful sunny day with a high of 25°C. Not a cloud in the sky."
  )

  "This is just an example, do not copy it."
}

The example weather conditions in the system instructions will be represented as JSON to help steer the model when generating structured outputs. FirebaseAI.Instructions are analogous to Instructions in the Foundation Models framework. When using hybrid inference, FirebaseAI.Instructions are converted to Instructions when starting the underlying LanguageModelSession.

#no-changelog

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@danger-firebase-ios
Copy link
Copy Markdown

1 Warning
⚠️ New public headers were added, did you remember to add them to the umbrella header?

Generated by 🚫 Danger

@andrewheard andrewheard changed the title [AI] Add SystemInstructions type with resultBuilder [AI] Add FirebaseAI.Instructions type with resultBuilder May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant