From the course: OpenAI API and MCP Development
Debugging and reviewing code with AI suggestions
From the course: OpenAI API and MCP Development
Debugging and reviewing code with AI suggestions
GitHub Models offers a set of built-in features to support prompt iteration, evaluation, and also AI integration. So we could see that after using several features and built-in tools in the Playground, and we're gonna discover also that GitHub Models also supports reusable prompts. And we could test already this tool, the Prompt Editor, to iterate over the same prompts using several language models, and then compare their results in order to select which language model could be the best suitable for our specific use case and business needs, for example. We're gonna see how to actually be able to reuse prompts and run a prompt within our own development environments. For example, we're gonna see how to create and use prompt files in VS Code. And I'm gonna show you how to do it also within Codespaces. So let's look at how we can create a prompt file. Basically, we want to define and configure instructions to send to the language models. And what is interesting is that we're going to be able to connect copilots to the GitHub models. We're going to prompt the models to analyze, for example, faulty code, suggest improvements, and generate refactored snippets directly within the code editor. And we're going to be able to do that within the chat copilot interface. I'm going to show you how. So the steps will be to create and add a prompt file. We're going to see how to use the prompt file in the chat interface of Copilot. You just need to use this forward slash command, the key, and then followed by the name of your prompt file. Let's go back up. So this is the steps to create one. So you're going to go to your VS Code and then open the chat Copilot interface, which is on the side panel of your VS Code. Then select prompt files, and then update, configure it with your own instructions that you want to send to the language models. Remember that whenever you want to generate content from the language model, you need to send an input that we call a prompt. But for this example, we're going to actually define a prompt file that we can reuse indefinitely when we need it. So let me show you now the steps. With a live example, and that's going to be within Cutspaces that we're going to do it. So let me show you where you can find Copilot. So that's going to be on the right. Here you can interact with a language model and ask questions. So you can work within your code spaces and at the same time interact with the language models to get some answers and tips about how to write your code, for example. So this is very convenient to have that side by side. And as a reminder, you also need to have an active Copilot extension and subscription in order to proceed with the next example. So first, I'm going to show you how to create a prompt file. And that's going to be here. So just like with the instructions, you just need to go here to configure the chat, select here, and then select prompt file. Here you can select new prompt file. Here we go. And we're going to create this one within this GitHub repository, and actually within a GitHub directory, and inside another directory that we named prompt. So this is done automatically. So this is where you're going to find it, so that's going to be in this path. Then you need to provide with a name. I'm going to name it Code Review, Prompt, and press Enter. And here you go. So now we've got a new prompt file which has been automatically created. So let's look at it. So you have nothing in it, so it's going to be named Agent. And here you're going to be prompted to define the task to achieve, including specific requirements, constraints, and success criteria. Basically what you do is to provide with detailed and precise instructions to send to the language model that you can then reuse multiple times, so whenever you need it, to perform a specific task. Instead of writing it from scratch right now, I'm going to provide you with instructions already available to you. Basically, what we want to do for the next task and example is to perform a detailed code review with clear actionable feedback on the main.py file. And we're going to specify also the the model to interact with. And the name of this prompt file is Code Review. Basically, what we want to do is to perform a task which is usually due and processed by human developers. But we're going to use the assistance of AI to run a code review to help us out with the development of our projects. So what we want as a task, so that's going to be specified right below. So we're going to indicate a persona to the language model. We're going to say that you're going to act as a senior software engineer responsible for performing a thorough code review following the steps. And we start with the goals. We also provide with instructions as to how we want the response and the output to be formatted. So we want first a section that gives a summary to describe the assessments and the feedback for the code, then list potential issues and risk, and finally, provide feedback about the readability and maintainability of the project. So to provide comments on the naming structure, et cetera. So we're gonna provide with this prompt that we can then reuse, and instead of just writing it, so we have to time prompt, so that's just a mistake, but you know that you should actually have something which is describing and meaningful enough. So I'm just going to go take this one and drag it within this prompt directory. And then I'm going to say yes to move. I'm going to remove this one, I don't need to use it. We're going to select and delete permanently. And you know that you can simply copy and paste. And you're going to find the same file within the corresponding exercise files that you can then download from the course page for your information. All right, so let's run this now. I'm going to save. So now we have that available. Let's see how we can actually use this within the Copilot chat interface. So I'm going to go here in the text input. And when you do forward slash, you're going to see this name showing up and it's going to actually show and display exactly the way that you have defined your prompt file. So starting with the name and the description. So what you're about to do and to execute is to perform a detailed code review of the main file of your project. So let's select this one and then press Enter. And in the chat interface, you're gonna see the result from the language model. So from this one, the one we have specified, line four, it's gonna follow these goals and this response format below. All right, so it's gonna start with a summary as instructed, followed by the step two, that includes a list of potential issues and risk. And finally, it's gonna finish with the last part, which is to check the readability and maintainability of the projects. All right, so it worked as expected, so that was very effective. So I just showed you how to create a prompt file to add to your code spaces, introduced to connect copilots with the GitHub models.