Skip to content

Conversation

@paulb777
Copy link
Member

@paulb777 paulb777 commented Oct 24, 2025

Adds template examples for Generate Content, Imagen, and Chat.

@gemini-code-assist
Copy link

Summary of Changes

Hello @paulb777, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a prototype for server-side prompt templates within the Firebase AI example application. It provides new UI screens and view models for generating content, images, and chat responses using predefined templates. This enhancement aims to demonstrate a more structured and reusable approach to interacting with generative AI models, although the chat template functionality is currently a work in progress.

Highlights

  • Server Prompt Templates: Introduced a prototype for server prompt templates to enable dynamic content generation.
  • New Examples: Added template examples for Generate Content, Imagen, and Chat functionalities, showcasing template-driven AI interactions.
  • Xcode Project Updates: Integrated new template-related Swift files into the Xcode project, updated the bundle identifier, and modified the Swift Package Manager dependency to a specific branch.
  • UI Integration: Added new navigation links in the ContentView to provide user interface access to the newly implemented template-based screens.
  • Chat Functionality Status: Noted that the 'Chat from Template' feature is currently not yet functional.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds prototypes for using server prompt templates for content generation, Imagen, and Chat. The changes are well-structured, adding new screens and corresponding view models, and updating the main content view to navigate to them. My feedback focuses on improving code quality by removing commented-out code, avoiding force unwraps, and using constants for hardcoded strings to enhance maintainability.


@MainActor
class GenerateContentFromTemplateViewModel: ObservableObject {
private var logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "generative-ai")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Force unwrapping Bundle.main.bundleIdentifier can cause a runtime crash if the identifier is unexpectedly nil. It's safer to provide a default value to prevent potential crashes.

Suggested change
private var logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "generative-ai")
private var logger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "com.google.firebase.VertexAISample", category: "generative-ai")

NavigationLink {
GenerateContentFromTemplateScreen(firebaseService: firebaseService)
} label: {
Label("Generate Content from Template", systemImage: "doc.text.fill")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoded UI strings should be avoided. It's better to define them as constants in a centralized location to improve maintainability and prepare for localization.

Comment on lines 74 to 76
ConversationFromTemplateScreen(firebaseService: firebaseService, title: "Chat from Template")
} label: {
Label("Chat from Template", systemImage: "ellipsis.message")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The screen title and Label text are hardcoded. For better maintainability and to ease future localization, it's recommended to define these UI strings as constants.

NavigationLink {
ImagenFromTemplateScreen(firebaseService: firebaseService)
} label: {
Label("Imagen from Template", systemImage: "camera.circle.fill")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoded UI strings should be avoided. It's better to define them as constants in a centralized location to improve maintainability and prepare for localization.

Comment on lines +45 to +53
Text("Enter your name, then tap on _Go_ to run generateContent from template on it.")
.padding(.horizontal, 6)
InputField("Enter your name", text: $userInput) {
Text("Go")
}
.focused($focusedField, equals: .message)
.onSubmit { onGenerateContentTapped() }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The instructional text and input field placeholder are hardcoded. It's a good practice to extract UI strings into a centralized constants structure. This makes the code cleaner, easier to maintain, and ready for localization.


init(firebaseService: FirebaseAI) {
model = firebaseService.templateGenerativeModel()
// model = firebaseService.generativeModel(modelName: "gemini-2.0-flash-001")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This commented-out code should be removed to keep the codebase clean and avoid confusion.

Comment on lines +57 to +79
templateID: "apple-qs-greeting",
inputs: [
"name": name,
"language": "Spanish",
]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoded strings like templateID and language can make the code harder to maintain. Consider extracting them into constants to improve readability and make them easier to update.

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.

2 participants