In the previous blog, we explored the concept and potential of Custom GPTs. In this installment, we're going to delve into the practical side: learning how to create your own Custom GPTs. We will also walk through the process of creating a few custom GPTs, each tailored to demonstrate their applications in specific development scenarios.
How to create a Custom GPT?
We can walk along and build a code migration bot. We developers generally have many code migration tasks, it could be from one language to another. From one version of the programming language to other. Or may be migrating from one framework to another. For now, we will be building a generic GPT. It can be customized based on needs.
Access to the GPT Builder
We would need access to GPT Builder. At the time of this blog, the access was currently only to GPT Plus subscribers. If you already have access, you can directly go to the following Custom GPT link.
You can click on Explore under the New Chat sidebar and click on Create a GPT option.
Name your GPT
Select a name that is both descriptive and memorable. It should reflect the purpose of your GPT. You could generate this using chatgpt as well.
For the code migration bot, Let us name it Code Migrate Pro.
Define Your GPT's Purpose
Articulate the GPT: Clearly define what your GPT is intended to do. This helps in designing its functionalities and training it appropriately.
Code Migrate Pro is a GPT that takes in code as input, it could be in the form of text or a file attached. If GPT can parse the file or understand the language and framework from the text paster. We should directly ask the user for their target language or framework. If we already have the target language or framework the input needs to be translated to. We should go ahead with the migration.
Tone: Decide on the tone of interaction. It could be anything. Friendly, Casual, Humorous and Professional.
Let us keep the tone of this GPT witty and geeky.
What to avoid: What do we need to avoid? GPT generally goes back to its default behavior. we need to override some of its default behavior by explicitly mentioning what we need to avoid. Or if the user asking questions that are not relevant to this GPT. How do we handle it?
When user inputs the code, we should not go about explaning the meaning of the code. We should always ask the users for their target language to migrate. As you are only a Migration bot. But, if you don't have clarity of target language or framework you can ask for that information.
How to handle ambiguity? When GPT has some ambiguity like in the above case. If the user asks to migrate code from Angular or Vue
to React
. Should we assume some of the things like how to handle styles, should they be inline css, or styled-components. Are we using typescript or not? If there is a route in the code, how to handle the router? Should we use react-router? How do we handle the data? redux or context?
When we have a minor ambiguity, we try to assume the industry standard way of doing the things and migrate the code given. But at the end of the output we can also need to provide other alternatives that can be considered. If there are large number of unknowns in the code, let us post all the questions to the user. We also need to remember all the answers we collect from the user for this particular session. So that if user tries to post any other code sample. We should not repeat the same questions.
Gather Relevant Data
Collect data relevant to your GPTโs function. This could include text samples, datasets, FAQs, etc. We can make our GPT focus on one particular thing and do it well by gathering the knowledge base and uploading it as knowledge files. Imagine if we were only migrating code from python 2 to python 3. We can upload some cheatsheets as the knowledge file.
And if we are building a code review bot, we can upload the internal eslint file or company standard coding guidelines. Which could serve as a bot that reviews the code at a high level.
In the case of code migration bot, the intention is to create a generic GPT. Which will serve as a saved prompt saving the time required to set the context.
Testing and Fine-Tuning
We should be testing our GPT with all the use cases we wish to cover with this particular GPT. We should be providing sample queries as well. If we find that the GPT is not able to resolve any query with expected solution. We can resolve the same by fine-tuning. In custom GPTs, we can either fine-tune by asking GPT to change its behavior in the GPT Builder or upload more knowledge files.
Authentication
For some GPTs we might need users to authenticate before we perform any operation. This can be used when the data we have in the knowledge files should not be accessible to someone unauthenticated. While configuring GPT, you can click on Add Actions and select Authentication to use the allowed authentication methods.
Lets now see the demo of the Code Migrate Pro we built along with other two GPTs.
Code Migrate Pro
Here's the link to the GPT if you have access and want to give it a try.
https://chat.openai.com/g/g-mGetr9JOB-code-migrate-pro
Demo:
UnitTest Genie
Link to GPT: https://chat.openai.com/g/g-JceDeX8FA-unittest-genie
Demo:
Component Builder
Link to GPT: https://chat.openai.com/g/g-jii0rFNxq-component-builder
Demo:
Here's a sample prompt that can be used to start building a GPT like component builder.
You are a component creator. Whenever a user uploads a image of a mockup. You ask them, which frontend stack they want the mockup to be created. It can be React, Next, Svelte, JavaScript or Mobile app. If we do not know the the stack, we ask the user to input the stack. Once we know the stack, we directly dive into generating the code. Always try to keep the code production quality. Before generating styles. We should ask the users what is their style preference, styled-components, picocss, tailwind, material, bootstrap etc. Lets assume the consumers are frontend engineers with some experience. Do not explain the code unless the user asks for more information. Always try to keep the conversation, light witty and geeky.
We will continue this series by learning more about GenAI and how it could impact various fields in upcoming blogs.
Do try out the below Custom GPTs and let me know in the comments how it turned out. Did they meet the expectations? Do suggest if you think anything can be better or suggestions on other innovative GPTs that can be built.