You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the following code with the thinking model. But cannot see the thought in the response.
fromgoogleimportgenai# Initialize the Gemini clientclient=genai.Client(api_key="YOUR_API_KEY", http_options={"api_version": "v1alpha"})
# Define the request configuration to include thoughtsconfig= {
"thinking_config": {"include_thoughts": True} # Enable thought process
}
# Send a request to the Gemini modelresponse=client.models.generate_content(
model="gemini-2.0-flash-thinking-exp-01-21",
contents="Solve 3*x^3-5*x=1.",
config=config
)
# Process and display the response, including thoughtsforpartinresponse.candidates.content.parts:
ifhasattr(part, "thought") andpart.thought: # Check if 'thought' existsprint(f"Model Thought Process:\n{part.text}\n")
else:
print(f"Model Final Response:\n{part.text}\n")
Relevant log output
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
File Name
gemini/getting-started/intro_gemini_2_0_flash_thinking_mode.ipynb
What happened?
Using the following code with the thinking model. But cannot see the thought in the response.
Relevant log output
Code of Conduct
The text was updated successfully, but these errors were encountered: