Skip to content

Conversation

@Aarchi-07
Copy link

No description provided.

@github-actions github-actions bot added the status:awaiting review PR awaiting review from a maintainer label Oct 15, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Aarchi-07, 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 JavaScript quickstart guide designed to educate developers on the effective use of system instructions with the Gemini API. It provides comprehensive, runnable examples that illustrate how to steer model behavior for various applications, from adopting specific personas in conversations to generating code based on precise requirements, thereby enhancing the model's contextual understanding and response customization.

Highlights

  • New JavaScript Quickstart: A new JavaScript quickstart file, System_instruction.js, has been added to demonstrate the use of system instructions with the Gemini API.
  • System Instruction Examples: The new quickstart includes practical examples of how to set system instructions for single-turn content generation (e.g., persona adoption), multi-turn conversations, and code generation tasks.
  • API Key Configuration Guidance: The file also provides clear instructions on securely configuring the Gemini API key using environment variables.
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 JavaScript version of the 'System Instructions' notebook. The implementation is a good start, but there are several areas for improvement regarding code quality and adherence to repository conventions. Specifically, the code relies on implicit global variables, which is a significant issue in JavaScript. I have also noted some character encoding problems with emojis in the markdown sections. Furthermore, the new notebook should be added to the quickstarts-js/README.md file to ensure it is discoverable, as per the style guide. Finally, I've suggested an improvement for model selection to make the example more interactive for users.

Comment on lines +43 to +45
module = await import("https://esm.sh/@google/[email protected]");
GoogleGenAI = module.GoogleGenAI;
ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
Copy link
Contributor

Choose a reason for hiding this comment

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

high

These variables are being created as implicit globals. In JavaScript, this is considered bad practice as it can lead to unexpected behavior and makes code harder to maintain. Please declare them using const since they are not reassigned.

const module = await import("https://esm.sh/@google/[email protected]");
const GoogleGenAI = module.GoogleGenAI;
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

Comment on lines +55 to +56
systemPrompt = "You are a cat. Your name is Neko.";
prompt = "Good morning! How are you?";
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The variables systemPrompt and prompt are created as implicit globals. They should be declared with let since their values are reassigned later in the script.

let systemPrompt = "You are a cat. Your name is Neko.";
let prompt = "Good morning! How are you?";

systemPrompt = "You are a cat. Your name is Neko.";
prompt = "Good morning! How are you?";

response = await ai.models.generateContent({
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The response variable is created as an implicit global. It should be declared with let since it is reassigned later in the script.

let response = await ai.models.generateContent({

*/

// [CODE STARTS]
chat = await ai.chats.create({
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The chat variable is created as an implicit global. Please declare it with const as it is not reassigned.

const chat = await ai.chats.create({

*/

// [CODE STARTS]
htmlString = response.text.trim().replace(/^```html/, "").replace(/```$/, "");
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The htmlString variable is created as an implicit global. Please declare it with const as it is not reassigned.

const htmlString = response.text.trim().replace(/^```html/, "").replace(/```$/, "");

GoogleGenAI = module.GoogleGenAI;
ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

MODEL_ID = "gemini-2.5-flash" // ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro"]
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The MODEL_ID variable is created as an implicit global. It should be declared with const. Additionally, to make the example more interactive for users, you should use the @param annotation. This allows users to easily switch between models in the UI, as recommended by the repository style guide.1

const MODEL_ID = "gemini-2.5-flash"; // @param ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro"] {"allow-input":true, "isTemplate": true}

Style Guide References

Footnotes

  1. The style guide recommends using a selector for model IDs to improve maintainability and user experience in notebooks.

Comment on lines +50 to +52
/* Markdown (render)
## Set the system instruction 🐱
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The emoji in this markdown header appears to be corrupted due to a file encoding issue. Please replace it with the correct emoji 🐱.

/* Markdown (render)
## Set the system instruction 🐱
*/

Comment on lines +80 to +82
/* Markdown (render)
## Another example ☠️
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The emoji in this markdown header appears to be corrupted due to a file encoding issue. Please replace it with the correct emoji ☠️.

/* Markdown (render)
## Another example ☠️
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:awaiting review PR awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant