In the earlier prompt, the ask was to read from a file and input into the mongodb. The file had a sensitive data which is the password, so I changed my prompt to include an encryption module using bcrypt. I identified the userPassword and requested the same to be encrypted before pushing into the database. I selected the entire earlier code base and then initiated the Co-Pilot with the prompt
- Prompt : "userDataset.csv is a file having userName, userPassword and userRole. Generate a golang program to read the contents of this file and push the contents onto a local mongodb host, having a database called bot. The userPassword must be encrypted using bcrypt before loading into the database."
- The interesting thing is the system gives me a diff between the old and the revised code base showing the changes, the first image shows the new libraries that have been put in place and the second image reflects how the bcrypt library is being put to use.
-
- I accepted the changes and cleared the collection from mongodb. I ran the code using go run main.go
- Here is the snapshot of the entries in the collection. They are all encrypted.
- This is really getting interesting. I tried couple of variations in the prompt to see if there are any changes to the recommended code base.
- I tried without mentioning bcrypt, the code generated was the same as bcrypt is the gold standard for encryption.
- I also tried this "userDataset.csv is a file having userName, userPassword and userRole. Generate a golang program to read the contents of this file and push the contents onto a local mongodb host, having a database called bot. The sensitive data must be encrypted using bcrypt before loading into the database". I did not quote password for encryption but rather kept it open ended calling for any sensitive data to be encrypted. The resulting code generated was the same. That's cool, Co-Pilot analyses all the data and classifies the right one to be encrypted.
- This is not very different to the previous scenario but I wanted to explore if the Co-Pilot can read a csv file in my project directory and generate the code to load into my local mongodb database. This csv file curatedContent.csv is a wide file having more than 10 columns.
- Well the Co-Pilot did not read the file. That would have been a great feature. I mean I thought I can skip giving the column names and that can be auto inferred from the CSV file.
- So instead I changed my prompt
- Prompt : "curatedContent.csv is a file having rowNumber,contentSubjectArea,contentSubjectAreaSubArea,learningContentId,learningStep,contentType,contentDescription,contentURL,smenotes,transcript,pycodeSnippet. Generate a golang program that reads the file curatedContent.csv and loads the same into mongodb database bot. Here rowNumber,learningContentId,learningStep are of type integer"
- The integer conversions are in place as per the instructions
- I ran the program and can see the mongodb collection all loaded in its entirety
As part of the next article I will explore more complex interactions with Co-Pilot, have it scan my existing code base. So far I have been trying to generate code that can load files into mongodb with a few changes here and there.
Happy learning and Keep experimenting. Share your experience with Github Co-Pilot. I would love to hear your experiences.
PhD in CSE (JU) || Product Owner || Gen AI Practitioner || Director @LTIMindtree|| Dedicated Researcher in Data Science, Gen AI || Mentor || Patents on AI/DS/Gen AI
1 年Great one Vishwa! Just one thought. For the second experiment, we are passing the column names to the prompt as it's unable to read from input file. So, can we break it into two parts to make it dynamic? In the first part, just pass the excel to LLM and ask to provide the column names and in the second part, we will add that answer in the prompt.