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

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

Open
kn0wn opened this issue Oct 23, 2024 · 0 comments
Open
Assignees
Labels
component:js sdk Issue/PR related to JavaScript SDK status:triaged Issue/PR triaged to the corresponding sub-team type:help Support-related issues

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.

@gmKeshari gmKeshari added type:help Support-related issues status:triaged Issue/PR triaged to the corresponding sub-team component:js sdk Issue/PR related to JavaScript SDK labels Oct 28, 2024
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 status:triaged Issue/PR triaged to the corresponding sub-team type:help Support-related issues
Projects
None yet
Development

No branches or pull requests

5 participants