async function handleToolCall()

in challenge5/frontend/components/voice-mode.tsx [137:170]


    async function handleToolCall(output: any) {
      const toolCall = {
        name: output.name,
        arguments: output.arguments
      }
      console.log('Tool call:', toolCall)

      const toolCallOutput: ToolCallOutput = {
        response: `Tool call ${toolCall.name} executed successfully.`
      }

      // Handle special tool calls
      if (toolCall.name === 'search_location') {
        const results = await fetch('/api/search_location', {
          method: 'POST',
          body: JSON.stringify(toolCall.arguments)
        }).then(response => response.json())
        toolCallOutput.search_results = results
      }

      sendClientEvent({
        type: 'conversation.item.create',
        item: {
          type: 'function_call_output',
          call_id: output.call_id,
          output: JSON.stringify(toolCallOutput)
        }
      })

      // Force a model response to make sure it responds after tool calls
      sendClientEvent({
        type: 'response.create'
      })
    }