awesome-llm-apps/ai_agent_tutorials/ai_gemini_thinking_agent/test2.py
2025-01-31 23:42:48 +05:30

21 lines
No EOL
612 B
Python

from google import genai
import os
from dotenv import load_dotenv
load_dotenv()
from google import genai
client = genai.Client(api_key=os.getenv("GOOGLE_API_KEY"), http_options={'api_version':'v1alpha'})
config = {'thinking_config': {'include_thoughts': True}}
response = client.models.generate_content(
model='gemini-2.0-flash-thinking-exp-01-21',
contents='Explain how RLHF works in simple terms.',
config=config
)
for part in response.candidates[0].content.parts:
if part.thought:
print(f"Model Thought:\n{part.text}\n")
else:
print(f"\nModel Response:\n{part.text}\n")