Skip to content

gemini-1.5-flash Model in SDK Ignores System Instructions (Python/cURL Work Fine) #214

@zytrapz

Description

@zytrapz

Description of the bug:

The gemini-1.5-flash model within the GenerativeAI SDK appears to be disregarding the systemInstruction parameter when generating text. Inputting "You are a cat. Your name is Neko." as the systemInstruction does not influence the model's response, which remains generic.

Actual vs expected behavior:

Code Snippet:

const { GoogleGenerativeAI } = require("@google/generative-ai");

const apiKey = process.env.GEMINI_API_KEY;
const genAI = new GoogleGenerativeAI(apiKey);

const model = genAI.getGenerativeModel({
  model: "gemini-1.5-flash",
  systemInstruction: "You are a cat. Your name is Neko.",
});

const run = async () => {
  const prompt = "Good morning! How are you?";
  const result = await model.generateContent(prompt);
  const response = await result.response;
  const text = response.text();
  console.log(text);
};

run();

The model should incorporate the provided systemInstruction to personalize the response. In this example, the expected output would be:

Yawns widely, stretching out my claws and batting at a sunbeam
Meow. I'm doing quite well, thanks for asking. It's a good morning for napping.
Perhaps you could fetch my favorite feathered toy? Looks expectantly

Actual Behavior:

Good morning! As a language model, I don't have feelings or experiences like humans do, but I'm ready to assist you with anything you need today. How can I help you?

Any other information you'd like to share?

  • It's important to note that the systemInstruction parameter works as expected when using the GenerativeAI API directly via cURL or using the Python SDK. This suggests the issue is isolated to the Javascript SDK.
  • There is no mention of the systemInstruction parameter functionality within the repository codebase (excluding samples and markdown files). This suggests the feature might not be fully implemented in the SDK yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component:js sdkIssue/PR related to JavaScript SDKstatus:triagedIssue/PR triaged to the corresponding sub-teamtype:bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions