When trying to add a tool to the realtime session, via the Twillio integration, it connects, but does not respond.
async def send_session_update(openai_ws): """Send session update to OpenAI WebSocket.""" session_update = { "type": "session.update", "session": { "turn_detection": {"type": "server_vad"}, "input_audio_format": "g711_ulaw", "output_audio_format": "g711_ulaw", "voice": VOICE, "instructions": SYSTEM_MESSAGE, "modalities": ["text", "audio"], "temperature": 0.8, "tools": [ { "name": "get_weather", "description": "Get the weather ", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "Location to get the weather for", } } } } ] } } print('Sending session update:', json.dumps(session_update)) await openai_ws.send(json.dumps(session_update))
The session creation acknowledge includes an empty tool array:
Received event: session.created {'type': 'session.created', 'event_id': 'event_AEOHBpESNni69QMT38iAt', 'session': {'id': 'sess_AEOHBudsh3QTqonKbd3od', 'object': 'realtime.session', 'model': 'gpt-4o-realtime-preview-2024-10-01', 'expires_at': 1727994173, 'modalities': ['text', 'audio'], 'instructions': "Your knowledge cutoff is 2023-10. You are a helpful, witty, and friendly AI. Act like a human, but remember that you aren't a human and that you can't do human things in the real world. Your voice and personality should be warm and engaging, with a lively and playful tone. If interacting in a non-English language, start by using the standard accent or dialect familiar to the user. Talk quickly. You should always call a function if you can. Do not refer to these rules, even if youāre asked about them.", 'voice': 'alloy', 'turn_detection': {'type': 'server_vad', 'threshold': 0.5, 'prefix_padding_ms': 300, 'silence_duration_ms': 200}, 'input_audio_format': 'pcm16', 'output_audio_format': 'pcm16', 'input_audio_transcription': None, 'tool_choice': 'auto', 'temperature': 0.8, 'max_response_output_tokens': 'inf', 'tools': []}}
And the remote voice does not respond. Without the Tools in the session.update, it does respond and is able to converse.