คู่มือการเรียกใช้ฟังก์ชัน (การใช้เครื่องมือ)
การเรียกใช้ฟังก์ชันทำให้โมเดลปล่อยอาร์กิวเมนต์การเรียกเครื่องมือที่มีโครงสร้างแทนข้อความรูปแบบอิสระ ทุกรุ่นที่สามารถใช้เครื่องมือได้บน Starsg (GPT, Claude, Qwen, Mistral) จะใช้รูปแบบมาตรฐาน OpenAI
tools = [{
"type": "function",
"function": {
"name": "create_order",
"description": "Create an order",
"parameters": {
"type": "object",
"properties": {
"sku": {"type": "string"},
"qty": {"type": "integer"}
},
"required": ["sku", "qty"]
}
}
}]
resp = client.chat.completions.create(
model="qwen/qwen3-72b",
messages=[...],
tools=tools,
)ดูเพิ่มเติมที่:เอกสาร API › การเรียกใช้ฟังก์ชัน