Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(js/ai): expose /util/model-runner action for the dev ui #2178

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Feb 26, 2025

Checklist (if applicable):

@pavelgj pavelgj requested a review from shrutip90 February 26, 2025 21:03
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.

Hello @pavelgj, 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!

Summary of Changes

I am currently reviewing this pull request. In the meanwhile, I am providing a summary of the content of the pull request for you and other reviewers to get up to speed quickly on the changes that have occurred, and the intent behind these changes.

This pull request introduces a new 'model-runner' action within the Genkit AI library. This action is designed to expose a utility function for running models directly through the development UI. The changes primarily involve adding a new action definition to the defineGenerateAction function in js/ai/src/generate/action.ts. This new action allows specifying a model and a request, and it handles both streaming and non-streaming execution of the model.

Highlights

  • New 'model-runner' Action: A new action named 'model-runner' is added to the Genkit AI library, enabling direct model execution from the dev UI.
  • Action Definition: The pull request modifies the defineGenerateAction function to include the new 'model-runner' action definition, specifying its input and output schemas.
  • Streaming and Non-Streaming Support: The 'model-runner' action supports both streaming and non-streaming execution of models, adapting the execution flow based on whether a sendChunk function is provided.

Changelog

  • js/ai/src/generate/action.ts
    • Added import for sentinelNoopStreamingCallback from @genkit-ai/core.
    • Modified defineGenerateAction to define a new 'model-runner' action.
    • Implemented logic within the 'model-runner' action to resolve the model, handle streaming/non-streaming execution, and invoke the model action.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Trivia time!

What is the purpose of the z object imported from @genkit-ai/core in the context of this pull request?

Click here for the answer
The `z` object, likely referring to Zod, is used for schema definition and validation. It helps ensure that the input and output data conform to the expected structures.

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.

@github-actions github-actions bot added the js label Feb 26, 2025
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

The changes introduce a new 'model-runner' action, which is a valuable addition for the dev UI. The code is well-structured, but there are a few areas that could be improved for clarity and maintainability.

Summary of Findings

  • Documentation of the new action: The new 'model-runner' action lacks a detailed description. Adding a comprehensive description would improve discoverability and understanding for developers using the dev UI.
  • TODO comment: The TODO comment indicates an incomplete implementation. Addressing this before merging would ensure the action is fully functional and avoids potential issues in the future.
  • Naming consistency: The comment on line 73 suggests the function defines multiple actions, but it actually defines two separate actions. Clarifying the comment to accurately reflect the function's purpose would improve code understanding.

Assessment

The pull request introduces a new 'model-runner' action that allows running models directly through the dev UI. The code is generally well-structured, but there are a few areas that could be improved for clarity and maintainability. I recommend addressing the comments before merging, and users should have others review and approve this code before merging.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant