blog-img

Initial Code


While all of the code generation works as per the prompt where one can add code chunks of code with the instruction. It is often times useful to add the initial code for each of the prompt in the promptset.


For example, here is an initial code for generating the NodeJS/ExpressJS/Sequelize data model generation.

—————————————————————————

   const Sequelize = require("sequelize");
   const sequelize = require("../../config/database");
   const { v4: uuidv4 } = require("uuid");
   const tableName = "@Function";

   const @Function = sequelize.define(
    "@Function",
    {
     id: {
      // Unique ID 
      type: Sequelize.STRING,
      defaultValue: Sequelize.UUIDV4,
      primaryKey: true,
     },
    }
    {
     indexes: [],
     createdAt: "cdt",
     updatedAt: "ldt",
     tableName,
    }
   );
    

   module.exports = @Function;



—————————————————————————


One can use this optionally in any programming language for in-fillig based code generation.


The last part of the promptset the core prompt itself. By using the structure of gen path, phase, and initial code, the prompt becomes far easier to build, test and debug.


For the above data model generation, the prompt is simply as follows:


————————————————————————————

   Add following data types in the model with appropriate type, defaultValue and allowNull values, if it doesn't exist already.
   @Model


————————————————————————————


Next: Instruction Set Review


Updated: Oct 11, 2024