Gemini 2.5 Pro Experimental و Gemini 2.0 Flash Thinking Experimental مدل هایی هستند که از یک «فرایند تفکر» داخلی در طول تولید پاسخ استفاده می کنند. این فرآیند به بهبود قابلیت های استدلال آنها کمک می کند و به آنها اجازه می دهد تا کارهای پیچیده را حل کنند. این راهنما به شما نشان می دهد که چگونه از مدل های Gemini با قابلیت های تفکر استفاده کنید.
از مدل های تفکر استفاده کنید
مدلهای دارای قابلیت تفکر در Google AI Studio و از طریق Gemini API در دسترس هستند. توجه داشته باشید که فرآیند تفکر در Google AI Studio قابل مشاهده است اما به عنوان بخشی از خروجی API ارائه نشده است.
یک درخواست اساسی ارسال کنید
from google import genai
client = genai.Client(api_key="GEMINI_API_KEY")
prompt = "Explain the concept of Occam's Razor and provide a simple, everyday example."
response = client.models.generate_content(
model="gemini-2.5-pro-exp-03-25", # or gemini-2.0-flash-thinking-exp
contents=prompt
)
print(response.text)
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "GEMINI_API_KEY" });
async function main() {
const prompt = "Explain the concept of Occam's Razor and provide a simple, everyday example.";
const response = await ai.models.generateContent({
model: "gemini-2.5-pro-exp-03-25", // or gemini-2.0-flash-thinking-exp
contents: prompt,
});
console.log(response.text);
}
main();
// import packages here
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY")))
if err != nil {
log.Fatal(err)
}
defer client.Close()
model := client.GenerativeModel("gemini-2.5-pro-exp-03-25") // or gemini-2.0-flash-thinking-exp
resp, err := model.GenerateContent(ctx, genai.Text("Explain the concept of Occam's Razor and provide a simple, everyday example."))
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Text())
}
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro-exp-03-25:generateContent?key=$YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [
{
"parts": [
{
"text": "Explain the concept of Occam\''s Razor and provide a simple, everyday example."
}
]
}
]
}'
```
مکالمات فکری چند نوبتی
برای در نظر گرفتن سابقه چت قبلی، می توانید از مکالمات چند نوبتی استفاده کنید.
با SDK ها، می توانید یک جلسه چت برای مدیریت وضعیت مکالمه ایجاد کنید.
from google import genai
client = genai.Client(api_key='GEMINI_API_KEY')
chat = client.aio.chats.create(
model='gemini-2.5-pro-exp-03-25', # or gemini-2.0-flash-thinking-exp
)
response = await chat.send_message('What is your name?')
print(response.text)
response = await chat.send_message('What did you just say before this?')
print(response.text)
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "GEMINI_API_KEY" });
async function main() {
const chat = ai.chats.create({
model: 'gemini-2.5-pro-exp-03-25' // or gemini-2.0-flash-thinking-exp
});
const response = await chat.sendMessage({
message: 'What is your name?'
});
console.log(response.text);
response = await chat.sendMessage({
message: 'What did you just say before this?'
});
console.log(response.text);
}
main();
بعدش چی؟
- Gemini 2.5 Pro Experimental را در Google AI Studio امتحان کنید.
- درباره مدلهای پیشنهادی برای تفکر بیشتر بیاموزید.
- برای اطلاعات بیشتر درباره Gemini 2.5 Pro Experimental و Gemini Flash 2.0 Thinking، به صفحه مدل مراجعه کنید.
- نمونه های بیشتری را در کتاب آشپزی Thinking امتحان کنید.