In AI Studio, it’s easy to see the google search’s sources used for the output
If i’m using the same code in python, the output only shows the website that’s using, instead of the actual sources,
After i added please include source url in output
in prompt, then it hallucinated some urls within the source, since those are generated instead of the actual ones used.
Note: last link from Nikkei Asia doesn’t exist on website
Is there a way to natively output the links from grounded search in the python output? This would greatly improved output’s trustworthiness
Hey @cubesat , You should be able to get the actual source information (similar to what you see in AI Studio) by accessing the grounding metadata from the response.
response.to_json_dict()["candidates"][0]["grounding_metadata"]["grounding_chunks"]
1 Like
you were actually correct, the issue comes from AI Studio’s bug. I’ve made a bug report post, hope it can be fixed
Issue:
With Google Search enabled, the SDK code does not include it in the output, causing confusion on whether I’m getting the correct result from search. Turns out the code provided was not complete.
Reproduce steps:
Enable google search
Get SDK code
Check the code, no google search in the code
It should include something similar to the following
google_search_tool = Tool(google_search=GoogleSearch())
generate_content_config = types.GenerateContentConfig(
thinking_config=types.Th…