Skip to content

Add FunctionGemma guide to keras#2299

Merged
hertschuh merged 8 commits intokeras-team:masterfrom
laxmareddyp:function_gemma_guide
Mar 10, 2026
Merged

Add FunctionGemma guide to keras#2299
hertschuh merged 8 commits intokeras-team:masterfrom
laxmareddyp:function_gemma_guide

Conversation

@laxmareddyp
Copy link
Collaborator

@laxmareddyp laxmareddyp commented Feb 25, 2026

This example demonstrates how to build a multi-tool AI Assistant using FunctionGemma native
function calling capabilities in KerasHub. The Assistant can execute multiple tools
including web search, stock prices, world time, and system stats.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @laxmareddyp, 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 new guide that demonstrates how to implement native function calling with FunctionGemma within the KerasHub ecosystem. It provides a practical example of building a multi-tool AI Assistant capable of interacting with external services and system information, thereby expanding the model's utility beyond text generation. The guide covers the full lifecycle of function calling, from tool definition to execution and response formatting, offering a valuable resource for developers looking to integrate advanced tool-use features into their AI applications.

Highlights

  • New Function Calling Guide: A comprehensive guide has been added to KerasHub demonstrating native function calling capabilities with FunctionGemma.
  • Multi-Tool AI Assistant: The guide showcases building an AI Assistant that integrates multiple tools, including web search, stock price retrieval, world time, and system statistics.
  • Native Function Calling Implementation: The guide details the implementation of FunctionGemma's native function calling format, covering tool definition, prompt formatting, and parsing structured function calls from model output.
  • KerasHub Integration: The new guide is integrated into the KerasHub documentation index, making it accessible to users.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • guides/keras_hub/function_gemma_with_keras.py
    • Added a new guide titled "Native Function Calling with FunctionGemma in KerasHub".
    • Implemented Python functions for web search, stock price retrieval, system statistics, and world time.
    • Defined tool schemas in Function Calling Format for FunctionGemma.
    • Created helper functions for parsing function calls, formatting tool declarations, constructing prompts, and formatting tool responses.
    • Included an interactive chat loop to demonstrate the multi-tool AI Assistant.
  • scripts/hub_master.py
    • Updated the GUIDES dictionary to include the new "Native Function Calling with FunctionGemma" guide.
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
Contributor

@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 introduces a new guide for using FunctionGemma with KerasHub for native function calling to build a multi-tool AI Assistant. While the guide is comprehensive and well-structured, it introduces a Prompt Injection vulnerability in the manual prompt construction logic, as user input is directly concatenated into the prompt without sanitizing model-specific control tokens. Additionally, there are suggestions to improve code quality, performance, and maintainability, such as correcting a date typo, enhancing exception handling, optimizing performance by avoiding object re-creation and regex re-compilation in loops, and improving code clarity by removing redundant code. A change to make the script directly runnable is also recommended for a better user experience.

Copy link
Contributor

@hertschuh hertschuh left a comment

Choose a reason for hiding this comment

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

Great! Can you generator the ipynb and md files?

@laxmareddyp
Copy link
Collaborator Author

laxmareddyp commented Mar 6, 2026

Great! Can you generator the ipynb and md files?

I’ve updated visualizing_what_convnets_learn.py to resolve the Black formatting issues that were blocking the incoming PR's. I also verified that the FunctionGemma .ipynb and .md files are generating correctly and rendering as expected on keras.io.

Please have a look once and merge. Thanks

+ cropped_width,
(cropped_height + margin) * i : (cropped_height + margin) * i
+ cropped_height,
(cropped_width + margin) * j : (cropped_width + margin) * j + cropped_width,
Copy link
Member

Choose a reason for hiding this comment

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

Is this diff intentional? Might need to rebase

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Initially i rebased and try to push my code but still it is failing due to these changes are required to pass black.

Copy link
Contributor

@hertschuh hertschuh left a comment

Choose a reason for hiding this comment

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

Thanks!

@hertschuh hertschuh merged commit 742c9ac into keras-team:master Mar 10, 2026
3 checks passed
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.

4 participants