Apple will compete next year with ChatGPT and Perplexity as it plans to build its own AI-based web search tool.