-
Notifications
You must be signed in to change notification settings - Fork 66
Description
I'm trying to get grounded responses using the @google-cloud/vertexai node package version 1.10.0.
First of all, I need to pass this as the tool as when using the format recommended in the npm package documentation throw a 400:
tools: [{
google_search: {},
} as any],
The doc indicates to use googleSearchRetrieval which is very counter-intuitive that it doesn't work out of the box.
When I was able to get the grounded data, it's misleading:
- I get only one response candidate
- The response has two parts
- The first part says the information couldn't be found (this part is the one I show to my users)
- The second part has the actual answer, it always works like that
I tried changing the temperature, the correct answer is always appearing in the second part.
I was asking the bot what's the latest cannabis legislation changes on cannabis signed by Donald Trump. Parts of the candidate:
"parts": [
{
"text": "Hey! I'm not aware of any cannabis regulation changes signed by Trump recently. He left office in January 2021. It is possible there have been changes since then, but to be sure, can someone in the Cogoland community confirm the latest updates on US cannabis regulations? Maybe someone has more specific information?\n"
},
{
"text": "Okay, here's the info on the latest cannabis regulation changes:\n\nTrump signed a bill in November 2025 that includes a controversial section to essentially recriminalize hemp products containing THC. This reverses the 2018 Farm Bill that he initially signed, which legalized hemp.\n\nHere's what the new legislation does:\n\n* It bans hemp products with more than 0.4 milligrams of total THC per container. This applies to the entire product, not just a single serving.\n* It outlaws any cannabinoid synthesized or manufactured outside of the cannabis plant, as well as any cannabinoid that cannot be naturally produced by the plant.\n* It prohibits the sale of any intermediate product directly to consumers.\n* It bans any cannabinoid with similar effects to THC, as determined by federal health regulators.\n\nThis new standard is set to take effect one year after the bill's enactment. Unless Congress intervenes, the ban will begin in November 2026.\n\nOther potential changes in cannabis regulation:\n\n* There's been discussion about rescheduling cannabis from Schedule I to Schedule III of the Controlled Substances Act. This could recognize the medical value of cannabis, open the door to federal research, and allow cannabis businesses to claim certain tax deductions. However, hearings on this have been delayed.\n* The SAFE Banking Act is also gaining traction. If passed, it would protect banks and financial institutions that work with legal cannabis companies.\n\nKeep in mind that cannabis laws are constantly evolving.\n"
}
]
So the first part has very outdated information. It even doesn't know yet that Trump is the president of the US. The second part has a proper up-to-date answer. Why does it appear as the second part always and not as the first part? Why aren't these two different candidates? How do I make the grounded answer, meaning the one that takes search results into consideration, to be the first part of the first candidate always? Am I misconfiguring the call?
Other params I'm using:
generationConfig: {
temperature: 0.1,
topP: 0.95,
topK: 40,
maxOutputTokens: 4096,
candidateCount: 1,
},
safetySettings: [
{
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
{
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
threshold: HarmBlockThreshold.BLOCK_ONLY_HIGH,
},
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_NONE,
},
],
tools: [{
google_search: {},
} as any],
Thank you.