ลายเซ็นความคิดคือการแสดงความคิดภายในของโมเดลที่เข้ารหัส
และใช้เพื่อรักษาบริบทการให้เหตุผลในการโต้ตอบแบบหลายรอบ
เมื่อใช้โมเดลการคิด (เช่น Gemini 3 และซีรีส์ 2.5) API อาจ
แสดงผลฟิลด์ thoughtSignature ภายในชิ้นส่วนเนื้อหา
ของคำตอบ (เช่น text หรือ functionCall)
โดยทั่วไปแล้ว หากคุณได้รับลายเซ็นความคิดในคำตอบของโมเดล คุณควรส่งลายเซ็นความคิดกลับไปตามที่ได้รับเมื่อส่งประวัติการสนทนา ในรอบถัดไป เมื่อใช้ Gemini 3 Pro คุณต้องส่งลายเซ็นความคิดกลับมาในระหว่างการเรียกใช้ฟังก์ชัน มิฉะนั้นคุณจะได้รับข้อผิดพลาดในการตรวจสอบ (รหัสสถานะ 4xx)
วิธีการทำงาน
กราฟิกด้านล่างแสดงความหมายของ "เทิร์น" และ "ขั้นตอน" ที่เกี่ยวข้องกับการเรียกใช้ฟังก์ชันใน Gemini API "เทิร์น" คือการแลกเปลี่ยนที่สมบูรณ์แบบครั้งเดียวในการสนทนาระหว่างผู้ใช้กับโมเดล "ขั้นตอน" คือการดำเนินการหรือการทำงานที่ละเอียดขึ้นซึ่งโมเดลดำเนินการ โดยมักเป็นส่วนหนึ่งของกระบวนการที่ใหญ่ขึ้นเพื่อดำเนินการให้เสร็จสมบูรณ์

เอกสารนี้มุ่งเน้นที่การจัดการการเรียกใช้ฟังก์ชันสำหรับ Gemini 3 Pro โปรดดูส่วนลักษณะการทำงานของโมเดลสำหรับความคลาดเคลื่อนกับ 2.5
Gemini 3 Pro จะแสดงลายเซ็นความคิดสำหรับคำตอบของโมเดลทั้งหมด (คำตอบจาก API) พร้อมการเรียกใช้ฟังก์ชัน ลายเซ็นความคิดจะปรากฏในกรณีต่อไปนี้
- เมื่อมีการเรียกใช้ฟังก์ชันแบบขนาน ส่วนการเรียกใช้ฟังก์ชันแรกที่การตอบกลับของโมเดลส่งคืนจะมี ลายเซ็นความคิด
- เมื่อมีการเรียกใช้ฟังก์ชันตามลำดับ (หลายขั้นตอน) การเรียกใช้ฟังก์ชันแต่ละครั้งจะมี ลายเซ็น และคุณต้องส่งลายเซ็นทั้งหมดกลับ
- คำตอบของโมเดลที่ไม่มีการเรียกใช้ฟังก์ชันจะแสดงลายเซ็นความคิดภายใน ส่วนสุดท้ายที่โมเดลแสดง
ตารางต่อไปนี้แสดงภาพการเรียกใช้ฟังก์ชันแบบหลายขั้นตอน โดยรวมคำจำกัดความของเทิร์นและขั้นตอนเข้ากับแนวคิดของลายเซ็น ที่แนะนำไว้ข้างต้น
เลี้ยว |
Step |
คำขอของผู้ใช้ |
คำตอบของโมเดล |
FunctionResponse |
1 |
1 |
request1 = user_prompt |
FC1 + signature |
FR1 |
1 |
2 |
request2 = request1 + (FC1 + signature) + FR1 |
FC2 + signature |
FR2 |
1 |
3 |
request3 = request2 + (FC2 + signature) + FR2 |
text_output
|
ไม่มี |
ลายเซ็นในส่วนการเรียกใช้ฟังก์ชัน
เมื่อ Gemini สร้าง functionCall จะใช้ thought_signature
เพื่อประมวลผลเอาต์พุตของเครื่องมืออย่างถูกต้องในรอบถัดไป
- พฤติกรรม
- การเรียกฟังก์ชันเดียว: ส่วน
functionCallจะมีthought_signature - การเรียกใช้ฟังก์ชันแบบขนาน: หากโมเดลสร้างการเรียกใช้ฟังก์ชันแบบขนาน
ในการตอบกลับ ระบบจะแนบ
thought_signatureเฉพาะกับส่วนแรกfunctionCallส่วนfunctionCallที่ตามมาในการตอบกลับเดียวกันจะไม่มีลายเซ็น
- การเรียกฟังก์ชันเดียว: ส่วน
- ข้อกำหนด: คุณต้องส่งคืนลายเซ็นนี้ในส่วนที่ได้รับเมื่อส่งประวัติการสนทนากลับ
- การตรวจสอบ: มีการบังคับใช้การตรวจสอบอย่างเข้มงวดสำหรับการเรียกใช้ฟังก์ชันทั้งหมดภายใน
เทิร์นปัจจุบัน (ต้องเป็นเทิร์นปัจจุบันเท่านั้น เราไม่ตรวจสอบเทิร์นก่อนหน้า)
- API จะย้อนกลับไปในประวัติ (ใหม่สุดไปเก่าสุด) เพื่อค้นหาข้อความผู้ใช้ล่าสุดที่มีเนื้อหามาตรฐาน (เช่น
text) ( ซึ่งจะเป็น จุดเริ่มต้นของเทิร์นปัจจุบัน) การดำเนินการนี้จะไม่befunctionResponse - การตอบกลับของโมเดล
functionCallทั้งหมดที่เกิดขึ้นหลังจากข้อความการใช้งานเฉพาะนั้นจะถือเป็นส่วนหนึ่งของการตอบกลับ - ส่วนแรกของ
functionCallในแต่ละขั้นตอนของเทิร์นปัจจุบัน ต้องมีthought_signatureของตัวเอง - หากคุณละเว้น
thought_signatureสำหรับส่วนfunctionCallแรกในขั้นตอนใดก็ตามของเทิร์นปัจจุบัน คำขอจะล้มเหลวพร้อมข้อผิดพลาด 400
- API จะย้อนกลับไปในประวัติ (ใหม่สุดไปเก่าสุด) เพื่อค้นหาข้อความผู้ใช้ล่าสุดที่มีเนื้อหามาตรฐาน (เช่น
- หากไม่ได้รับลายเซ็นที่ถูกต้อง คุณจะได้รับข้อผิดพลาดดังนี้
gemini-3-pro-preview: การไม่ใส่ลายเซ็นจะทำให้เกิดข้อผิดพลาด 400 ข้อความจะมีรูปแบบดังนี้- การเรียกใช้ฟังก์ชัน
<Function Call>ในบล็อกเนื้อหา<index of contents array>ไม่มีthought_signatureเช่น Function callFC1ในบล็อกเนื้อหา1.ไม่มีthought_signature
- การเรียกใช้ฟังก์ชัน
ตัวอย่างการเรียกใช้ฟังก์ชันแบบต่อเนื่อง
ส่วนนี้แสดงตัวอย่างการเรียกใช้ฟังก์ชันหลายรายการที่ผู้ใช้ถาม คำถามที่ซับซ้อนซึ่งต้องใช้หลายงาน
มาดูตัวอย่างการเรียกใช้ฟังก์ชันแบบหลายรอบที่ผู้ใช้ถามคำถามที่ซับซ้อนซึ่งต้องทำหลายอย่างกัน"Check flight status for AA100 and
book a taxi if delayed"
เลี้ยว |
Step |
คำขอของผู้ใช้ |
คำตอบของโมเดล |
FunctionResponse |
1 |
1 |
request1="Check flight status for AA100 and book a taxi 2 hours before if delayed." |
FC1 ("check_flight") + signature |
FR1 |
1 |
2 |
request2 = request1 + FC1 ("check_flight") + signature + FR1 |
FC2("book_taxi") + signature |
FR2 |
1 |
3 |
request3 = request2 + FC2 ("book_taxi") + signature + FR2 |
text_output
|
None |
โค้ดต่อไปนี้แสดงลำดับในตารางด้านบน
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำขอของผู้ใช้)
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "check_flight",
"description": "Gets the current status of a flight",
"parameters": {
"type": "object",
"properties": {
"flight": {
"type": "string",
"description": "The flight number to check"
}
},
"required": [
"flight"
]
}
},
{
"name": "book_taxi",
"description": "Book a taxi",
"parameters": {
"type": "object",
"properties": {
"time": {
"type": "string",
"description": "time to book the taxi"
}
},
"required": [
"time"
]
}
}
]
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำตอบของโมเดล)
{
"content": {
"role": "model",
"parts": [
{
"functionCall": {
"name": "check_flight",
"args": {
"flight": "AA100"
}
},
"thoughtSignature": "<Signature A>"
}
]
}
}
เทิร์นที่ 1 ขั้นตอนที่ 2 (การตอบกลับของผู้ใช้ - การส่งเอาต์พุตของเครื่องมือ) เนื่องจากเทิร์นของผู้ใช้รายนี้มีเพียง functionResponse (ไม่มีข้อความใหม่) เราจึงยังอยู่ในเทิร์นที่ 1 เราต้องอนุรักษ์<Signature_A>
{
"role": "user",
"parts": [
{
"text": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "check_flight",
"args": {
"flight": "AA100"
}
},
"thoughtSignature": "<Signature A>" //Required and Validated
}
]
},
{
"role": "user",
"parts": [
{
"functionResponse": {
"name": "check_flight",
"response": {
"status": "delayed",
"departure_time": "12 PM"
}
}
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 2 (โมเดล) ตอนนี้โมเดลตัดสินใจจองแท็กซี่ตามเอาต์พุตของเครื่องมือก่อนหน้า
{
"content": {
"role": "model",
"parts": [
{
"functionCall": {
"name": "book_taxi",
"args": {
"time": "10 AM"
}
},
"thoughtSignature": "<Signature B>"
}
]
}
}
เทิร์น 1 ขั้นตอนที่ 3 (ผู้ใช้ - เอาต์พุตเครื่องมือส่ง) หากต้องการส่งการยืนยันการจองแท็กซี่
เราต้องใส่ลายเซ็นสำหรับการเรียกใช้ฟังก์ชันทั้งหมดในลูปนี้
(<Signature A> + <Signature B>)
{
"role": "user",
"parts": [
{
"text": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "check_flight",
"args": {
"flight": "AA100"
}
},
"thoughtSignature": "<Signature A>" //Required and Validated
}
]
},
{
"role": "user",
"parts": [
{
"functionResponse": {
"name": "check_flight",
"response": {
"status": "delayed",
"departure_time": "12 PM"
}
}
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "book_taxi",
"args": {
"time": "10 AM"
}
},
"thoughtSignature": "<Signature B>" //Required and Validated
}
]
},
{
"role": "user",
"parts": [
{
"functionResponse": {
"name": "book_taxi",
"response": {
"booking_status": "success"
}
}
}
]
}
}
ตัวอย่างการเรียกใช้ฟังก์ชันแบบขนาน
มาดูตัวอย่างการเรียกใช้ฟังก์ชันแบบขนานที่ผู้ใช้ขอ
"Check weather in Paris and London" เพื่อดูว่าโมเดลทําการตรวจสอบที่ใด
เลี้ยว |
Step |
คำขอของผู้ใช้ |
คำตอบของโมเดล |
FunctionResponse |
|---|---|---|---|---|
1 |
1 |
request1="ตรวจสอบสภาพอากาศในปารีสและลอนดอน" |
FC1 ("ปารีส") + ลายเซ็น FC2 ("ลอนดอน") |
FR1 |
1 |
2 |
คำขอ 2 = คำขอ 1 + FC1 ("ปารีส") + ลายเซ็น + FC2 ("ลอนดอน") |
text_output (ไม่มี FC) |
ไม่มี |
โค้ดต่อไปนี้แสดงลำดับในตารางด้านบน
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำขอของผู้ใช้)
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Check the weather in Paris and London."
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_current_temperature",
"description": "Gets the current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name, e.g. San Francisco"
}
},
"required": [
"location"
]
}
}
]
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำตอบของโมเดล)
{
"content": {
"parts": [
{
"functionCall": {
"name": "get_current_temperature",
"args": {
"location": "Paris"
}
},
"thoughtSignature": "<Signature_A>"// INCLUDED on First FC
},
{
"functionCall": {
"name": "get_current_temperature",
"args": {
"location": "London"
}// NO signature on subsequent parallel FCs
}
}
]
}
}
เทิร์นที่ 1 ขั้นตอนที่ 2 (การตอบกลับของผู้ใช้ - การส่งเอาต์พุตของเครื่องมือ) เราต้องเก็บรักษา
<Signature_A> ส่วนแรกไว้ตามที่ได้รับ
[
{
"role": "user",
"parts": [
{
"text": "Check the weather in Paris and London."
}
]
},
{
"role": "model",
"parts": [
{
"functionCall": {
"name": "get_current_temperature",
"args": {
"city": "Paris"
}
},
"thought_signature": "<Signature_A>" // MUST BE INCLUDED
},
{
"functionCall": {
"name": "get_current_temperature",
"args": {
"city": "London"
}
}
} // NO SIGNATURE FIELD
]
},
{
"role": "user",
"parts": [
{
"functionResponse": {
"name": "get_current_temperature",
"response": {
"temp": "15C"
}
}
},
{
"functionResponse": {
"name": "get_current_temperature",
"response": {
"temp": "12C"
}
}
}
]
}
]
ลายเซ็นในส่วนที่ไม่ใช่ functionCall
นอกจากนี้ Gemini อาจแสดง thought_signatures ในส่วนสุดท้ายของคำตอบ
ในส่วนที่ไม่ได้ใช้การเรียกใช้ฟังก์ชันด้วย
- ลักษณะการทำงาน: ส่วนเนื้อหาสุดท้าย (
text, inlineData…) ที่โมเดลส่งคืนอาจมีthought_signature - คำแนะนำ: ขอแนะนำให้ส่งคืนลายเซ็นเหล่านี้เพื่อให้มั่นใจว่า โมเดลจะยังคงให้เหตุผลคุณภาพสูง โดยเฉพาะอย่างยิ่งสำหรับคำสั่งที่ซับซ้อน หรือเวิร์กโฟลว์ของเอเจนต์จำลอง
- การตรวจสอบ: API ไม่บังคับใช้การตรวจสอบอย่างเคร่งครัด คุณจะไม่ได้รับข้อผิดพลาดเกี่ยวกับการบล็อกหากละเว้นการระบุ แต่ประสิทธิภาพอาจลดลง
การให้เหตุผลแบบข้อความ/ในบริบท (ไม่มีการตรวจสอบ)
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำตอบของโมเดล)
{
"role": "model",
"parts": [
{
"text": "I need to calculate the risk. Let me think step-by-step...",
"thought_signature": "<Signature_C>" // OPTIONAL (Recommended)
}
]
}
เทิร์นที่ 2 ขั้นตอนที่ 1 (ผู้ใช้)
[
{ "role": "user", "parts": [{ "text": "What is the risk?" }] },
{
"role": "model",
"parts": [
{
"text": "I need to calculate the risk. Let me think step-by-step...",
// If you omit <Signature_C> here, no error will occur.
}
]
},
{ "role": "user", "parts": [{ "text": "Summarize it." }] }
]
ลายเซ็นสำหรับความเข้ากันได้ของ OpenAI
ตัวอย่างต่อไปนี้แสดงวิธีจัดการลายเซ็นความคิดสำหรับ API การเติมข้อความแชทโดยใช้ความเข้ากันได้ของ OpenAI
ตัวอย่างการเรียกใช้ฟังก์ชันแบบต่อเนื่อง
นี่คือตัวอย่างการเรียกใช้ฟังก์ชันหลายรายการที่ผู้ใช้ถามคำถามที่ซับซ้อน ซึ่งต้องใช้หลายงาน
มาดูตัวอย่างการเรียกใช้ฟังก์ชันแบบหลายรอบที่ผู้ใช้ถามว่า
Check flight status for AA100 and book a taxi if delayed และคุณจะเห็นว่าเกิดอะไรขึ้นเมื่อผู้ใช้ถามคำถามที่ซับซ้อนซึ่งต้องใช้หลายงาน
เลี้ยว |
Step |
คำขอของผู้ใช้ |
คำตอบของโมเดล |
FunctionResponse |
1 |
1 |
request1="Check the weather in Paris and London" |
FC1 ("Paris") + signature
|
FR1 |
1 |
2 |
request 2 = request1 + FC1 ("Paris") + signature + FC2 ("London") |
text_output
|
None |
โค้ดต่อไปนี้จะแสดงลำดับที่ระบุ
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำขอของผู้ใช้)
{
"model": "google/gemini-3-pro-preview",
"messages": [
{
"role": "user",
"content": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
}
],
"tools": [
{
"type": "function",
"function": {
"name": "check_flight",
"description": "Gets the current status of a flight",
"parameters": {
"type": "object",
"properties": {
"flight": {
"type": "string",
"description": "The flight number to check."
}
},
"required": [
"flight"
]
}
}
},
{
"type": "function",
"function": {
"name": "book_taxi",
"description": "Book a taxi",
"parameters": {
"type": "object",
"properties": {
"time": {
"type": "string",
"description": "time to book the taxi"
}
},
"required": [
"time"
]
}
}
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำตอบของโมเดล)
{
"role": "model",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature A>"
}
},
"function": {
"arguments": "{\"flight\":\"AA100\"}",
"name": "check_flight"
},
"id": "function-call-1",
"type": "function"
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 2 (การตอบกลับของผู้ใช้ - การส่งเอาต์พุตของเครื่องมือ)
เนื่องจากเทิร์นของผู้ใช้รายนี้มีเพียง functionResponse (ไม่มีข้อความใหม่) เราจึงยังอยู่ในเทิร์นที่ 1 และต้องเก็บ <Signature_A> ไว้
"messages": [
{
"role": "user",
"content": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
},
{
"role": "model",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature A>" //Required and Validated
}
},
"function": {
"arguments": "{\"flight\":\"AA100\"}",
"name": "check_flight"
},
"id": "function-call-1",
"type": "function"
}
]
},
{
"role": "tool",
"name": "check_flight",
"tool_call_id": "function-call-1",
"content": "{\"status\":\"delayed\",\"departure_time\":\"12 PM\"}"
}
]
เทิร์นที่ 1 ขั้นตอนที่ 2 (โมเดล)
ตอนนี้โมเดลจะตัดสินใจจองแท็กซี่โดยอิงตามเอาต์พุตของเครื่องมือก่อนหน้า
{
"role": "model",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature B>"
}
},
"function": {
"arguments": "{\"time\":\"10 AM\"}",
"name": "book_taxi"
},
"id": "function-call-2",
"type": "function"
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 3 (ผู้ใช้ - ส่งเอาต์พุตของเครื่องมือ)
หากต้องการส่งการยืนยันการจองแท็กซี่ เราต้องใส่ลายเซ็นสำหรับการเรียกใช้ฟังก์ชันทั้งหมดในลูปนี้ (<Signature A> + <Signature B>)
"messages": [
{
"role": "user",
"content": "Check flight status for AA100 and book a taxi 2 hours before if delayed."
},
{
"role": "model",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature A>" //Required and Validated
}
},
"function": {
"arguments": "{\"flight\":\"AA100\"}",
"name": "check_flight"
},
"id": "function-call-1d6a1a61-6f4f-4029-80ce-61586bd86da5",
"type": "function"
}
]
},
{
"role": "tool",
"name": "check_flight",
"tool_call_id": "function-call-1d6a1a61-6f4f-4029-80ce-61586bd86da5",
"content": "{\"status\":\"delayed\",\"departure_time\":\"12 PM\"}"
},
{
"role": "model",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature B>" //Required and Validated
}
},
"function": {
"arguments": "{\"time\":\"10 AM\"}",
"name": "book_taxi"
},
"id": "function-call-65b325ba-9b40-4003-9535-8c7137b35634",
"type": "function"
}
]
},
{
"role": "tool",
"name": "book_taxi",
"tool_call_id": "function-call-65b325ba-9b40-4003-9535-8c7137b35634",
"content": "{\"booking_status\":\"success\"}"
}
]
ตัวอย่างการเรียกใช้ฟังก์ชันแบบขนาน
มาดูตัวอย่างการเรียกใช้ฟังก์ชันแบบขนานที่ผู้ใช้ถามว่า
"Check weather in Paris and London" และคุณจะเห็นว่าโมเดลทําการตรวจสอบ
ที่ใด
เลี้ยว |
Step |
คำขอของผู้ใช้ |
คำตอบของโมเดล |
FunctionResponse |
1 |
1 |
request1="Check the weather in Paris and London" |
FC1 ("Paris") + signature
|
FR1 |
1 |
2 |
request 2 = request1 + FC1 ("Paris") + signature + FC2 ("London") |
text_output
|
None |
นี่คือโค้ดที่จะใช้ในการดำเนินการตามลำดับที่ระบุ
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำขอของผู้ใช้)
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Check the weather in Paris and London."
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_current_temperature",
"description": "Gets the current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name, e.g. San Francisco"
}
},
"required": [
"location"
]
}
}
]
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 1 (คำตอบของโมเดล)
{
"role": "assistant",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature A>" //Signature returned
}
},
"function": {
"arguments": "{\"location\":\"Paris\"}",
"name": "get_current_temperature"
},
"id": "function-call-f3b9ecb3-d55f-4076-98c8-b13e9d1c0e01",
"type": "function"
},
{
"function": {
"arguments": "{\"location\":\"London\"}",
"name": "get_current_temperature"
},
"id": "function-call-335673ad-913e-42d1-bbf5-387c8ab80f44",
"type": "function" // No signature on Parallel FC
}
]
}
เทิร์นที่ 1 ขั้นตอนที่ 2 (การตอบกลับของผู้ใช้ - การส่งเอาต์พุตของเครื่องมือ)
คุณต้องเก็บรักษา <Signature_A> ในส่วนแรกตามที่ได้รับ
"messages": [
{
"role": "user",
"content": "Check the weather in Paris and London."
},
{
"role": "assistant",
"tool_calls": [
{
"extra_content": {
"google": {
"thought_signature": "<Signature A>" //Required
}
},
"function": {
"arguments": "{\"location\":\"Paris\"}",
"name": "get_current_temperature"
},
"id": "function-call-f3b9ecb3-d55f-4076-98c8-b13e9d1c0e01",
"type": "function"
},
{
"function": { //No Signature
"arguments": "{\"location\":\"London\"}",
"name": "get_current_temperature"
},
"id": "function-call-335673ad-913e-42d1-bbf5-387c8ab80f44",
"type": "function"
}
]
},
{
"role":"tool",
"name": "get_current_temperature",
"tool_call_id": "function-call-f3b9ecb3-d55f-4076-98c8-b13e9d1c0e01",
"content": "{\"temp\":\"15C\"}"
},
{
"role":"tool",
"name": "get_current_temperature",
"tool_call_id": "function-call-335673ad-913e-42d1-bbf5-387c8ab80f44",
"content": "{\"temp\":\"12C\"}"
}
]
คำถามที่พบบ่อย
ฉันจะโอนประวัติจากโมเดลอื่นไปยัง Gemini 3 Pro โดยมีส่วนการเรียกใช้ฟังก์ชันในเทิร์นและขั้นตอนปัจจุบันได้อย่างไร ฉันต้องระบุส่วนการเรียกใช้ฟังก์ชันที่ API ไม่ได้สร้างขึ้นและจึงไม่มีลายเซ็นความคิดที่เชื่อมโยงใช่ไหม
แม้ว่าเราจะไม่แนะนำอย่างยิ่งให้แทรกบล็อกการเรียกใช้ฟังก์ชันที่กำหนดเองลงในคำขอ แต่ในกรณีที่หลีกเลี่ยงไม่ได้ เช่น การให้ข้อมูลแก่โมเดลเกี่ยวกับการเรียกใช้ฟังก์ชันและการตอบกลับที่ไคลเอ็นต์ดำเนินการอย่างแน่นอน หรือการโอนการติดตามจากโมเดลอื่นที่ไม่มีลายเซ็นความคิด คุณสามารถตั้งค่าลายเซ็นจำลองต่อไปนี้ของ
"context_engineering_is_the_way_to_go"หรือ"skip_thought_signature_validator"ในช่องลายเซ็นความคิดเพื่อข้ามการตรวจสอบได้ฉันส่งการเรียกใช้ฟังก์ชันและการตอบกลับแบบขนานที่สลับกัน และ API แสดงผล 400 ทำไมจึงเป็นเช่นนั้น
เมื่อ API แสดงผลการเรียกใช้ฟังก์ชันแบบขนาน "FC1 + ลายเซ็น, FC2" การตอบกลับจากผู้ใช้ที่คาดไว้คือ "FC1 + ลายเซ็น, FC2, FR1, FR2" หากคุณมีข้อมูลที่สลับกันเป็น "FC1 + ลายเซ็น, FR1, FC2, FR2" API จะแสดงข้อผิดพลาด 400
เมื่อสตรีมและโมเดลไม่แสดงผลการเรียกใช้ฟังก์ชัน ฉันจะหาลายเซ็นความคิดไม่เจอ
ในระหว่างการตอบกลับของโมเดลที่ไม่มี FC พร้อมคำขอสตรีม โมเดลอาจแสดงลายเซ็นความคิดในส่วนที่มีเนื้อหาข้อความว่างเปล่า ขอแนะนำให้แยกวิเคราะห์คำขอทั้งหมดจนกว่าโมเดลจะส่งคืน
finish_reason
ลักษณะการทำงานของลายเซ็นความคิดตามชุดโมเดล
โมเดล Gemini 3 Pro และ Gemini 2.5 จะทำงานแตกต่างกันเมื่อมีลายเซ็นความคิด ในการเรียกใช้ฟังก์ชัน ดังนี้
- หากมีการเรียกใช้ฟังก์ชันในการตอบกลับ ให้ทำดังนี้
- Gemini 3 Pro จะมีลายเซ็นในส่วนการเรียกใช้ฟังก์ชันแรกเสมอ คุณต้องส่งคืนชิ้นส่วนดังกล่าว
- Gemini 2.5 จะมีลายเซ็นในส่วนแรก (ไม่ว่าจะเป็นประเภทใดก็ตาม) คุณไม่จำเป็นต้องส่งคืนชิ้นส่วนดังกล่าว
- หากไม่มีการเรียกใช้ฟังก์ชันในคำตอบ
- Gemini 3 Pro จะมีลายเซ็นในส่วนสุดท้ายหากโมเดลสร้างความคิด
- Gemini 2.5 จะไม่มีลายเซ็นในส่วนใดๆ
ดูพฤติกรรมลายเซ็นความคิดของโมเดล Gemini 2.5 ได้ที่หน้าการคิด