Skip to content

Conversation

@MengqinShen
Copy link
Contributor

@MengqinShen MengqinShen commented Dec 20, 2025

CHANGELOG:

  1. Update main function of the prompt demo sample, all prompts are loaded automatically
  2. Update prompt demo : there are two flows can be tested

@github-actions github-actions bot added docs Improvements or additions to documentation feature New feature or request python Python labels Dec 20, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @MengqinShen, 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 significant enhancements to how prompts are managed and used within the Genkit framework. The primary goal is to streamline the developer experience by enabling automatic loading of prompts from designated directories and providing more flexible ways to customize prompt rendering through Handlebars helpers. These changes aim to make prompt-driven development more intuitive and less verbose, reducing boilerplate code for prompt initialization and improving template functionality.

Highlights

  • Automatic Prompt Loading: The Genkit instance now supports automatic loading of .prompt files from a specified directory (prompt_dir) during initialization, or defaults to ./prompts if that directory exists.
  • Handlebars Helper Registration: A new define_helper method has been added to the Genkit registry, allowing users to register custom Handlebars helper functions for use within prompts, enhancing template customization.
  • Simplified Prompt Naming: Prompts loaded from folders no longer include the dotprompt/ namespace prefix, simplifying their lookup and usage within the Genkit framework.
  • Frontmatter Stripping for Partials: The prompt loading mechanism now automatically strips YAML frontmatter from partial .prompt files, ensuring that only the template content is processed.
  • Prompt Demo Update: The prompt_demo sample has been updated to showcase the new automatic prompt loading and the registration of custom Handlebars helpers, reflecting best practices.

🧠 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.

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.

@MengqinShen MengqinShen changed the title Elisa/feat/loading prompts automatically feat(py): loading prompts automatically Dec 20, 2025
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 convenient feature to automatically load prompts from a directory upon Genkit initialization. The implementation is mostly solid, with related changes to prompt loading functions and updates to a sample application to demonstrate the new functionality. My main concerns are:

  1. A large test file (generate_test.py) has been deleted without an apparent replacement, which is a critical issue that could lead to regressions.
  2. An existing test case in prompt_test.py was emptied of its implementation.
  3. There are a few opportunities for code cleanup and clarification in the new Genkit initialization logic and the updated sample code.

Overall, the feature is a good addition, but the testing-related changes need to be addressed before merging.

I am having trouble creating individual review comments. Click here to see my feedback.

py/packages/genkit/tests/genkit/blocks/generate_test.py (1-419)

critical

This entire test file, which contains numerous tests for generate_action (including middleware, streaming, and spec-based tests), has been removed. Deleting tests without replacing them is risky and can lead to regressions. If these tests are still relevant, they should be restored or equivalent coverage should be added elsewhere. Could you clarify the reason for this removal?

py/packages/genkit/src/genkit/ai/_aio.py (84-85)

medium

The docstring for prompt_dir is a bit misleading. It states that it defaults to './prompts', but the argument's default value is None. The behavior is to check for './prompts' only if prompt_dir is not provided. A more accurate description would improve clarity.

            prompt_dir: Directory to automatically load prompts from.
                If not provided, defaults to loading from './prompts' if it exists.

py/packages/genkit/src/genkit/ai/_aio.py (91-94)

medium

This logic for determining which prompt directory to load is a bit repetitive. It can be simplified by using a variable to hold the path to load, which avoids calling load_prompt_folder in two different places and hardcoding the './prompts' path.

        load_path = prompt_dir
        if load_path is None:
            default_prompts_path = Path('./prompts')
            if default_prompts_path.is_dir():
                load_path = default_prompts_path

        if load_path:
            load_prompt_folder(self.registry, dir_path=load_path)

py/packages/genkit/tests/genkit/blocks/prompt_test.py (544)

medium

The implementation of test_prompt_function_uses_lookup_prompt has been removed, leaving an empty test. Empty tests provide no value and can be misleading. This test should either be completed to verify the prompt() helper function or removed entirely.

py/samples/prompt_demo/prompts/nested/nested_hello.prompt (1-2)

medium

The frontmatter from the original nested_hello.prompt file, which defined the model and input schema, has been removed. While the default model is now set during Genkit initialization, removing the input schema definition could be confusing, as there's no longer a defined contract for its input. If this prompt is intended as a complete example, please consider re-adding the frontmatter, at least for the input schema, to make it self-contained.

py/samples/prompt_demo/src/prompt_demo.py (34)

medium

The my_helper function accepts *args and **kwargs but does not use them. To improve clarity, it's best to remove unused parameters from function signatures.

def my_helper(content):

@MengqinShen MengqinShen marked this pull request as ready for review December 20, 2025 01:59
@MengqinShen MengqinShen requested a review from yesudeep December 20, 2025 02:00
@yesudeep yesudeep enabled auto-merge (squash) December 20, 2025 03:02
@yesudeep yesudeep merged commit e2a1508 into main Dec 20, 2025
10 checks passed
@yesudeep yesudeep deleted the elisa/feat/loading-prompts-automatically branch December 20, 2025 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation feature New feature or request python Python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants