Мое намерение состоит в том, чтобы не модель автоматически вызывала инструменты. Вместо этого я хочу явно запустить определенную функцию, используя response.create с помощью Tool_choice.
Это мое определение функции и пример обновления моего сеанса для инициализации.
Определение функции
Код: Выделить всё
{
"type": "function",
"name": "CaptureOrderInfo",
"description": "Extract order details mentioned in the conversation.",
"parameters": {
"type": "object",
"properties": {
"order_details": {
"type": "string",
"description": "What the customer ordered"
},
"phone_number": {
"type": "string",
"description": "Customer phone number"
},
"discount_coupon": {
"type": "string",
"description": "Coupon or discount mentioned"
}
},
"required": ["phone_number"]
}
}
Код: Выделить всё
session.updateКод: Выделить всё
{
"type": "session.update",
"session": {
"type": "realtime",
"model": "gpt-realtime",
"audio": {
"input": {
"turn_detection": { "type": "server_vad" }
},
"output": {
"voice": VOICE
}
},
"instructions": "",
"tools": [CaptureOrderInfo],
"tool_choice": "none"
}
}
Ручной внеполосный вызов функции (
Код: Выделить всё
response.createКод: Выделить всё
{
"type": "response.create",
"response": {
"conversation": "none",
"output_modalities": ["text"],
"tools": ["CaptureOrderInfo"],
"metadata": {
"topic": "CaptureOrderInfo"
},
"tool_choice": {
"type": "function",
"name": "CaptureOrderInfo"
}
}
}
Код: Выделить всё
{
"type": "response.done",
"response": {
"object": "realtime.response",
"status": "completed",
"status_details": null,
"output": [
{
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "{}"
}
]
}
],
"conversation_id": null,
"output_modalities": ["text"],
"max_output_tokens": "inf",
"audio": {
...
}
},
"metadata": {
"topic": "CaptureOrderInfo"
}
}
Подробнее здесь: https://stackoverflow.com/questions/798 ... altime-api
Мобильная версия