-
Notifications
You must be signed in to change notification settings - Fork 234
Using the ChatVertexAI class, even when informing the thinking_budget attribute, the thoughts are not being received with the response #910
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
Comments
@luisfelippe note that currently thoughts are not returned in the response even when related discussion at https://discuss.ai.google.dev/t/thoughts-are-missing-cot-not-included-anymore/63653/14 |
@windkit I understand, but if you look at the link you sent, it is about Gemini 2.0, but the Gemini 2.5 flash model returns. I am using the code below and I am receiving the thinking block. client = genai.Client( responses = client.models.generate_content_stream( first_thought = True for response in responses: |
which model are you testing with? I have just tried both |
@windkit I'm testting using gemini-2.5-flash-preview-04-17 model. It is extremely important to declare include_thoughts as true, because if you do not include it, the thoughts will not be returned. This is the print generated with the code I provided: --- Raciocínio --- Assessing the Question's Scope I need to understand the "how" of quantum sensors impacting "materials science" and "navigation", as per the query. So, I'm breaking down the prompt. This means outlining what quantum sensors are, the principles behind their accuracy, and the use of examples. Dissecting the Inquiry's Core I'm taking the query apart. It's materials science and navigation, precision improvement, and quantum sensors. The plan: definitions, principles, applications, examples, and benefits. I'll need to quickly define what the quantum sensors are, and touch on their super sensitivity. Examining the Core Concepts Right, I need to define quantum sensors, explain the principles of high precision (quantum effects like superposition), then how that applies to the query's fields: materials science and navigation. That means examples are key. I'll have to touch on what quantum sensors can measure. Revisiting the Approach Alright, I need to refine the plan. The prompt wants to focus on the application of quantum sensors. I'm going back to the key question, and then listing the benefits and concrete examples. The use cases are key. Outlining the Quantum Approach Right, I need to break down the specifics of how quantum sensors benefit both materials science and navigation, like the query specifies. The core idea is to explore why quantum sensors are precise: principles, examples, and applications. I'll look at each domain to outline the sensors and benefits. Confirming Key Aspects I'm reviewing the requirements, and ensuring I touch on all the specifics requested: quantum sensor principles, materials science and navigation applications with examples, and the benefits as outlined in the query. Time to focus on the core definitions. Mapping the Plan of Action Right, I need to break down the query. I must define quantum sensors and their principles, then illustrate how materials science and navigation benefit, with examples. It's all about precision: defining the quantum sensors and the underlying principles. Clarifying Precision Focus The core query is how quantum sensors make materials science and navigation more precise. Considering the prompt, I'm breaking down each area, and then addressing quantum principles. I need to focus on explaining why these sensors are better. --- Resposta --- Okay, let's break down how quantum sensors achieve enhanced precision and how this translates into improvements in materials science and navigation. The fundamental advantage of quantum sensors lies in their ability to leverage quantum mechanical properties – such as superposition, entanglement, and interference – to achieve levels of sensitivity and stability far beyond their classical counterparts. They are often designed to probe and measure physical quantities (like magnetic fields, electric fields, temperature, rotation, acceleration, gravity, or time) with exquisite detail by observing how these quantities affect the quantum state of a system (like a single atom, trapped ion, or defect in a crystal). Here's how this leads to improved precision and its impact: The Source of Enhanced Precision in Quantum Sensors:
Impact on Precision in Materials Science: In materials science, precision often means measuring properties with high spatial resolution, high sensitivity to weak signals, or under specific conditions. Quantum sensors excel here:
Impact on Precision in Navigation: Navigation traditionally relies on external signals (like GPS) or internal dead reckoning using inertial navigation systems (INS) composed of classical accelerometers and gyroscopes. Quantum sensors offer significant precision improvements, particularly for INS:
Overall Benefit in Navigation:
In summary, quantum sensors harness the fundamental principles of quantum mechanics to create measurement devices with unprecedented sensitivity, resolution, and stability. This enhanced precision allows materials scientists to probe material properties at scales and with sensitivities previously impossible and enables navigation systems that are significantly more accurate, stable, and resilient, especially in challenging environments. |
@luisfelippe thanks for the example, I will check and add the support. |
Note that |
@windkit Yes, I even got this error when changing the ChatVertexAI and _VertexAICommon classes. Using the native, according to the code I provided, the ThinkingConfig class used is being imported from google.genai.types. Here is the complete code: from google import genai
from google.genai.types import (
FunctionDeclaration,
GenerateContentConfig,
GoogleSearch,
HarmBlockThreshold,
HarmCategory,
Part,
SafetySetting,
ThinkingConfig,
Tool,
ToolCodeExecution,
)
models = {
"Gemini 2.5 Flash": {
"model_type": "LLM",
"deployment_name": "gemini-2.5-flash-preview-04-17",
"version": "",
"max_tokens": 1048576,
"max_words": 680000,
"max_tokens_out": 65535,
"max_reasoning_tokens": 4096,
"icon": "icon-ia-gemini",
"description": "Bom para codificações e prompts complexos",
"tiktoken_modelo": "",
"tiktoken_encodding": "",
"fornecedora": "VERTEXAI",
"regiao": None,
"stream_support": True,
"reasoning": True,
"disponivel": False,
"is_beta": False,
"inputs": {"text": True, "image": True, "audio": True, "video": True},
"outputs": {"text": True, "image": False, "audio": False, "video": False},
},
}
model = models["Gemini 2.5 Flash"]
PROJECT_ID = "PROJECT_ID"
LOCATION = "us-central1"
MODEL_ID = model['deployment_name'] # "gemini-2.5-flash-preview-04-17"
THINKING_BUDGET = model["max_reasoning_tokens"]
INCLUDE_THOUGHTS = True
client = genai.Client(
vertexai=True,
project=PROJECT_ID,
location=LOCATION
)
responses = client.models.generate_content_stream(
model=MODEL_ID,
contents="How might quantum sensors improve the precision of measurements in fields like materials science or navigation?",
config=GenerateContentConfig(
thinking_config=ThinkingConfig(
thinking_budget=THINKING_BUDGET,
include_thoughts=INCLUDE_THOUGHTS,
)
),
)
first_thought = True
first_answer = True
for response in responses:
for part in response.candidates[0].content.parts:
if part.thought and first_thought:
first_thought = False
print("\n--- Raciocínio ---\n")
elif not part.thought and first_answer:
first_answer = False
print("\n--- Resposta ---\n")
print(part.text, end="") |
Using the ChatVertexAI class, even when informing the thinking_budget attribute, the thoughts are not being received with the response. Perhaps the include_thoughts attribute is missing in ThinkingConfig, or even considered in the response parse.
The text was updated successfully, but these errors were encountered: