Skip to content

sendMessageStream with history failing to fetch due to 'empty text parameter' #286

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

Closed
kn0wn opened this issue Oct 23, 2024 · 1 comment
Closed
Assignees
Labels
component:js sdk Issue/PR related to JavaScript SDK p2 status: awaiting user response Awaiting a response from the author type:bug Something isn't working

Comments

@kn0wn
Copy link

kn0wn commented Oct 23, 2024

Description of the bug:

Hi!

I've got quite a basic setup for this error, I'm using Vue.

[400] Unable to submit request because it has an empty text parameter. Add a value to the parameter and try again.

Setup is as follows;

const model = getGenerativeModel(vertexAI, {
  model: "gemini-1.5-flash",
});

const chat = reactive(
  model.startChat({
    history: [
      {
        role: "user",
        parts: [{ text: "Hi, What is your current dataset?" }],
      },
      {
        role: "model",
        parts: [
          {
            text: `My product data set is: ${JSON.stringify(products.value)}`,
          },
        ],
      },
    ],
  })
);

async function sendMessage() {
  const result = await chat.sendMessageStream(question.value);

  for await (const chunk of result.stream) {
    const chunkText = chunk.text();
    generatedText.value += chunkText;
  }
}

I'm then just calling sendMessage with an updated question.value. When I look at the history, I can see that the model has an empty text part which could be the issue, but I'm not entirely sure!

Actual vs expected behavior:

Error output instead of an updated generatedText

Any other information you'd like to share?

Possible history culprit

[
    {
        "text": "I"
    },
    {
        "text": "'m sorry, I don't have information about that - but I can"
    },
    {
        "text": " help you with other questions. \n"
    },
    {
        "text": ""
    }
]

Edit: I noticed that I have ${JSON.stringify(products.value)} in the example, but even without it I'm still getting the same error, let me know if you need a minimal repro.

@IvanLH
Copy link
Collaborator

IvanLH commented Feb 26, 2025

We merged a fix to the SDK, can you verify this is not happening to you on version 0.22?

@IvanLH IvanLH added status: awaiting user response Awaiting a response from the author and removed status:triaged Issue/PR triaged to the corresponding sub-team labels Feb 26, 2025
@IvanLH IvanLH assigned IvanLH and unassigned lahirumaramba, hsubox76 and junyanxu Feb 26, 2025
@IvanLH IvanLH added type:bug Something isn't working p2 status: awaiting user response Awaiting a response from the author and removed status: awaiting user response Awaiting a response from the author type:help Support-related issues labels Feb 26, 2025
@IvanLH IvanLH closed this as completed Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:js sdk Issue/PR related to JavaScript SDK p2 status: awaiting user response Awaiting a response from the author type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants