-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_thoughts.py
More file actions
39 lines (32 loc) · 1.39 KB
/
check_thoughts.py
File metadata and controls
39 lines (32 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
"""Check if response has thoughts."""
import os
from google import genai
from google.genai import types
api_key = os.environ.get('GEMINI_API_KEY')
client = genai.Client(api_key=api_key)
response = client.models.generate_content(
model="models/gemini-2.5-flash",
contents="Summarize: 48 car detections in 60 minutes",
config=types.GenerateContentConfig(
temperature=0.3,
max_output_tokens=1000
)
)
print("Finish reason:", response.candidates[0].finish_reason if response.candidates else "none")
print("Usage:", response.usage_metadata if hasattr(response, 'usage_metadata') else "none")
if response.candidates:
candidate = response.candidates[0]
print("\nCandidate content:", candidate.content)
print("Content parts:", candidate.content.parts if candidate.content else "none")
if candidate.content and candidate.content.parts:
for i, part in enumerate(candidate.content.parts):
print(f"\nPart {i}:")
print(f" Type: {type(part)}")
print(f" Has text: {hasattr(part, 'text')}")
print(f" Has thought: {hasattr(part, 'thought')}")
if hasattr(part, 'text') and part.text:
print(f" Text: {part.text[:100]}")
if hasattr(part, 'thought') and part.thought:
print(f" Thought: {part.thought[:100]}")
print("\nResponse.text:", response.text)