I'm curious to know what are some of the best prompts to use on ChatGPT to understand its full-fledged capability as a newbie developer.
One of the things I noticed, is that it produces the requested code in the cleanest manner but it's not complete. For instance, I tried the prompt - "give me the python code for TicTacToe Game" and the code produced was incomplete.
Have you all encountered the same or my prompt is inappropriate?
ChatGPT is sensitive to how you prompt it, and it's designed to work as a dialogue where you ask further questions and it can refine its answer.
It can already write reasonable working code, although you shouldn't expect it to spit out entire working programs when the prompt is Gimme Teh Codez without further details. That being said, AI capabilities only get better with time, so I think it'd be shortsighted to dismiss its potential because of its current limitations.
If the pace keeps up, companies with access to large language models in a few years could have a large advantage on legacy programming, the same way programmers in high-level languages have a massive productivity advantage on 1970's low-level assembly programmers. You give up a little more control, but you save time.
You can't tell it to "create a CRUD app", but you can ask it to create a nodejs function that gets all the records from a mongodb database.
Anyway, when this happens just use the prompt : “continue”. From this it’ll generally do a good job of continuing where it left off, but some refactoring is often required. As it doesn’t always exactly begin where it ended and leaves out vital code or in complete event handlers and functions for example.
From an initial prompt, you may need to continue several times Ron get to complete code you’re after.
Of course, you can throw the resultant incomplete buggy code back in as a new prompt and request analysis and bug fixes. Which it does a good job of resolving.
Of course, all of this subject to the complexity of your perk or/request
It made a playable game, that was close to the output that it suggested would occur, but it did have a few mistakes - it missed 2 win conditions (rows and one of the diagonals), and the output didn't quite align fully (i.e. "" instead of " " being printed and no lines for board edges, it also doubled up the diagonal checks oddly.
# Check if there is a winner, and if so, print a message indicating who won
if board[0][0] == board[1][1] == board[2][2] and board[0][0] != "":
print(f"Player {board[0][0]} wins")
elif board[0][2] == board[1][1] == board[2][0] and board[0][2] != "":
print(f"Player {board[0][2]} wins")
else:
# If there is no winner, the game is a draw
print("It's a draw!")
It took me a while to find the right prompt to fix this as it seems to confuse the code checking for game over, which checks for a winner as one of the conditions, for the code that checks for the winner at the end of the game.One of my prompts led to the output being made the program be refactored into a function run in a loop rather than a one shot game. and then I tried:
>the play_game function prints the wrong output when there is a winner in the columns or rows
and got the desired fix.
I like the stateful nature of this.
For your example, I'd ask it to 'generate code, using Python, that accepts input and updates a display to allow a user to play an interactive game of TicTacToe with the computer.' I'm sure I could do better with some experimentation, but that will have to wait for some other day.
ChatGPT is a subset & tweak of the full GPT-3 model to make a good chatbot, and it's actually less capable than the full model.
It's strange to me that people are going crazy over ChatGPT when GPT-3 has been out for months now.
More info on the difference between ChatGPT and GPT-3: https://dev.to/ben/the-difference-between-chatgpt-and-gpt-3-...
https://github.com/pdparchitect/ChatGPT-JobsForBots and https://github.com/pdparchitect/ChatGPT-Pong were two of them.
The author shows all the steps used to generate the programs.
I want you to send a single function in each response, I will say "Next" when I want you to send the next function.
I was able to get it to generate decently lengthy programs using this (on the order of a few hundred lines) that were syntactically and logically correct without any modification.
This may work for some languages better than others, though I imagine you can find some way to logically split up the program for most.
So far it's created some pretty amazing tailwindcss layouts for me, and a flutter app to interface with chatGPT that I want to add more features like saving, sharing, etc.. In 3 hours with zero flutter experience I can now at least do as much as the website does. That's pretty amazing.
Edit: YMMV -- imho you do need to be mid-senior level in tech/programming skills to know and find the best prompts to get it to go your way, there's some trial and error and your ide will usually let you know about errors/etc and you can ask them to fix it and gpt does a good job of correcting things.
Its worst nightmare was that there were some nested values in the .txt. What amazed me the most is that pasting the error code from colab into the chat, it recognized the mistake and generated a fix.
That being said, most of the times it would try to fix a logical mistake by overengineering a solution to an error, or it would identify the mistake correctly, explain in natural language what needs to be done (impressive), but then give me the code unchanged.
I bet that you could break-up your app into functions and have ChatGPT write each function to get to a bigger program.
It's limited now but I can definitely see the possibilities.
It won't be free forever so we'll have to weight the usefulness vs cost eventually.
Having said that, I usually compare it with Junior programmers, more like someone just learning a new programming language. You can expect that level of performance from ChatGPT!
It's kinda crazy how fast my opinion went from "haha neat, the robot can write poems" to "this is an invaluable tool and I am begging you to let me pay for stable access". I use it multiple times per day, it's easily saved me hours already.
Seems like there would be far more content to train on and less restrictive criteria.
it has a token cap so it stopped once it filled them.
You can ask to explain code, write tests, refactor for perfomance or readability etc.
Write a small application in javascript that logs in to news.ycombinator.com with credentials passed on the command line and then posts the following message:
>Fellow members,
>
>I'm curious to know what are some of the best prompts to use on ChatGPT to understand its full-fledged capability as a newbie developer.
>
>One of the things I noticed, is that it produces the requested code in the cleanest manner but it's not complete. For instance, I tried the prompt - "give me the python code for TicTacToe Game" and the code produced was incomplete.
>
>Have you all encountered the same or my prompt is inappropriate?
Output:Here is an example of a small JavaScript application that logs in to news.ycombinator.com using credentials passed on the command line and then posts the message you provided:
// First, we need to import the `request` module, which will allow us to make HTTP requests to the Hacker News API
const request = require('request');
// Next, we need to parse the username and password from the command line arguments
const username = process.argv[2];
const password = process.argv[3];
if (!username || !password) {
// If the username or password is not provided, print an error message and exit the program
console.log("Error: Please provide a username and password as command line arguments");
return;
}
// Now we can use the `request` module to make a POST request to the Hacker News login API endpoint
// In the request, we need to provide the username and password as part of the request body
request.post({
url: 'https://hacker-news.firebaseio.com/v0/login.json',
body: JSON.stringify({
"username": username,
"password": password
})
}, (error, response, body) => {
if (error) {
// If there is an error, print it to the console
console.log(error);
return;
}
// If the login was successful, the API will return the user's authentication token
// We need to save this token so that we can use it in subsequent requests
const authToken = JSON.parse(body).token;
// Now that we have the authentication token, we can use it to post a new message on Hacker News
// To do this, we need to make a POST request to the `item` endpoint, providing the authentication token as part of the request headers
request.post({
url: 'https://hacker-news.firebaseio.com/v0/item.json',
headers: {
"Authorization": `Bearer ${authToken}`
},
body: JSON.stringify({
"title": "Best Prompts for ChatGPT",
"text": "Fellow members, I'm curious to know what are some of the best prompts to use on ChatGPT to understand its full-fledged capability as a newbie developer. One of the things I noticed, is that it produces the requested code in the cleanest manner but it's not complete. For instance, I tried the prompt - \"give me the python code for TicTacToe Game\" and the code produced was incomplete. Have you all encountered the same or my prompt is inappropriate?"
})
}, (error, response, body) => {
if (error) {
// If there is an error, print it to the console
console.log(error);
return;
}
// If the request was successful, the API will return the ID of the newly-created post
const postId = JSON.parse(body).id;
console.log(`Successfully posted message with ID ${postId}`);
});
});
To use this code, you would need to save it to a file (e.g. hacker-news-post.js) and then run it from the command line, providing your username and password as arguments: