From the course: Build a JavaScript AI App with React and the OpenAI API
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Advanced calls to the OpenAI API
From the course: Build a JavaScript AI App with React and the OpenAI API
Advanced calls to the OpenAI API
- [Instructor] To get our human language description of the weather data, we need to add in a new call to the OpenAI API in our sequence of calls, and that happens in useApiRequests.jsx. Here we already have a model for what we need to do, we need to take some data, pass it off to a component, and then in that component, make the API call. And here I'll leverage the most favored tool of all developers, which is to cheat by copying existing code I already have. Because, I already have this component prompt to location that I know successfully talks to the OpenAI API. So now that I'm going to do the same thing again, I'll just copy that component into a new file, and then give it a new name. So I'll find prompter location here, highlight everything inside, then go back to components, and create a new file, called this one WeatherDecript.jsx. And paste all that code in. And just for safety, I'm going to close prompt to location…