So when you work with AI models, prompt engineering is very important is because you specify what you want and AI knows what you want. It will do some work and it will give you the required information. But see now, we have to look at from a developer's perspective. See when you build application, you want data from AI, right? Now in general, when you want data, where you look for? We look for data in the database, right? So we have the application, we try to get this data from database and or maybe let's say front end. If front end wants data, it will get it from the back end. Now how do you send data from the back end to the front end? You use a format. Now this format can be XML format or this can be a JSON format and now nowadays we use JSON format. On the other hand, if you have a back end which is asking for the data from some other server, even there you transfer JSON data. So that means we are used to work with JSON formats, right? So if you have an object, let's say in Java or Python, you basically try to fetch data and you want to convert that data from JSON to object format. In the same way, if you want to fetch data from AI, in what format you're looking for? Of course, JSON. Now till this point, when we worked with the prompt engineering, we were basically working with the text and it's okay to get text, but then how will you pass it? How will you make a use of those those text? And specifically, when you talk about AI, you don't get the standard text from the AI. Sometime you get extra stuff, sometime you get the main thing at the end. So, you can't predict that and that's where you have to work with the structured output. Now how do you get it? And to do that, let's take an example of an application which needs the data about a particular phone. So, let's say you're building an application where you want to show data about a phone. So, I will say, I need details of iPhone air. Okay. Uh so when I do that, now it's already launched, right? iPhone is there in the market, you can buy it. I mean, should you buy it or not, that's a different question, but you can buy it. And if you say enter, it should say, this is the phone which was launched and these are the price. Uh let's see what it says. It says, iPhone air is a model of iPhone lineup announced in blah blah blah. Okay, good. So, it's able to fetch the data which we need. Okay, so everything is there. Now, before making a video, I was doing some experiments and once it it said that it is rumored that iPhone air is going to launch. So, maybe even Gemini don't have the updated data about iPhone. Maybe it's Google versus Apple. I'm not sure, but this time it is giving you that's good thing. But, you have to also assume that AI might not give you the correct information or the latest information, right? So, just by saying I need details of an iPhone air might not give you the exact information. So, if you want exact information, what you can do is you can say, uh I need details about iPhone air, and you can also add a source in case if LLM is not able to find data about it. Uh we'll talk about this concept later what I'm doing now, how I'm injecting the source in the prompt. We have some concept for it, or maybe it's more about adding context to the prompts. And when I do that, it will specifically go to that website, scan, understand what is happening and then it will give you the answer. So, even maybe this is right, and this should be right because we have passed the source now. And if you go up here, let's look at the price section. So, when I looked at the price, okay, nowhere there's a price, is it? Or maybe I'm not able to find anywhere. But then even if it gives you a price, and maybe you can see on the screen, it might give you in dollars. Now, specifically, I'm recording this video from India, so it should give me Indian price, and when I pass the source, it is IN here. And that's why you can see we got the price in rupees. Additionally, it should give you some more information. It's not doing that now. Uh in my experiment, it was giving option of colors and okay, there's a section here. Okay. So, everything is you you got it here. But again, the problem is it is giving you data in the text format. How will you pass this in the application? Now that's where you can ask AI to give this information in the JSON format. So, what I will do is I will just copy this part because I want to reuse it, and paste it here. But additionally, I will mention, give me this information in JSON format. Okay, when I do that, it will give you JSON format. That's what we are requesting for, right? So, it is its job to give that data in JSON format. And yeah, you got it. So, you can see uh it is giving this data iPhone air, announced, released, okay that's good. So, it is able to give the data, pricing in Indian MRP, we got all these details and okay, looks good. Looks good. This is how the JSON data should be, right? But there are chances that it will give you some extra details. Okay, by the way, you can unlock the full functionality of all the apps and able, Oh, okay, this is a new feature. Not sure. But you can see with this data, it is also giving you some text, okay? And this is what we don't want. So, if you, I mean, not the same text every time, but it might give give you some additional text with the JSON. We don't want additional text. So, what you can do is you can use the same prompt, but you can add more details here. And let me show you that details. And I I do have it here so that I don't have to do that and type that by myself. So, this is the additional prompt. So, instead of saying, give me this information JSON format, I can just write this, "Respond only with valid JSON object," because then it will also validate if the JSON which is sending is correct or not. Uh in this case, I'm not sure if this is a valid JSON. And I have the feeling now, it's not a valid JSON. Okay, and you let me know why in the chat. This is closing here. Where is the opening? Okay, this is not a valid JSON. Okay, that's good. Uh so now I'm mentioning, respond only with valid JSON object and do not include any text or explanation. I'll just keep it copied so that we can reuse it later. And now it says in a locker, previous search already provided JSON information, so another search is not required. Okay. So, it is not doing the thing which I want. Very bad. I paid for it. Let me do that once again. Why is not doing it? Let me go for a new chat. I don't know what went wrong there. Is it a scenario where when it gives you one information, it will not repeat? Sorry for the first time. Let me know if you have faced that before. Okay, now you got a JSON format and which looks a valid JSON format. If not, let me know in the chat. Okay, looks like a valid JSON. Cool. And you can see there's no extra text anywhere. Not at the start, not at the end, and this is what you need, right? So, this is how basically you can work with JSON JSON format. But there is one more thing which is missing here, which is, or not a missing part, but then if you think as a as a developer, when you build objects, right? So, to represent a particular data, you build objects, right? And this object will have certain properties. So, let's say I want a phone class, and iPhone class have this properties where you got the model name, you got the price, you got the RAM, CPU. So, you have a limited set of properties which you want to assign to. If you look at this JSON, it has a lot of data which maybe I don't need. Uh example, let's say maybe I don't need optical zooming of 1X 2X, maybe I don't need uh the USB speed. Okay? So, it is giving you everything. A good thing, but we don't require those things. So, how do you specify what JSON format you need? Now, in this case, I have one more prompt here and I will show you that prompt step-by-step. So, this is a prompt and let me just go through this one by one. So, at the start, I'm saying, you are an expert data extraction system. So, I'm also specifying a role there. And if you remember, we have talked about role prompting. Your task is to extract, so we are specifying the instruction, the key specification for iPhone air, input, from providing text format into JSON format. So, I'm specifying the output format, and this output format should be a valid JSON. Do not uh put any explanation or text. Then, we are specifying the JSON object format. So, this JSON object must strictly adhere to the following schema, extracting the information from the text below. So, I need model name. We don't need to specify the model name, maybe in future, I'm going to work with Samsung or uh maybe OnePlus, whatever the type is, of phone is. Then, uh you can specify the type or display, then, processor, what else we have? Design, and operating system. So, these are the details I want, and I'm also specifying the source from where you will get this. And when I do that, it will return the JSON format exactly in that format. Let's see. And yeah, you got it. So, you can see we got model name, display, processor, camera, design, and operating system, right? So, yeah, this is what you can do when you work with the AI to give you JSON data. So, your prompt needs to be good. You have to specify the role, you have to specify the JSON JSON format, and we can work with it. Now, how do you use that in the code? We are going to see that later. Okay, so I hope you will enjoy that. I hope you enjoyed this part. See you in the next video.