Skip to content

Commit a0b81af

Browse files
committed
complete proof t1
1 parent 47fed26 commit a0b81af

File tree

1 file changed

+42
-28
lines changed

1 file changed

+42
-28
lines changed

src/content/tutorials/en/criticalAI1-chatting-with-about-code.mdx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ This tutorial teaches you how to use generative AI to write p5.js code — inclu
2828

2929
## How to use it: Code-generating AI
3030

31-
You are likely familiar with text-generating AI tools like ChatGPT. They might seem intelligent, but they actually use statistics. They predict what is most likely to appear next, based on having analyzed huge amounts of existing text. They do this so convincingly that they can even generate code!
31+
You are likely familiar with text-generating AI tools like ChatGPT. They might seem like they are channelling human brilliance, but they actually just use statistics. They predict what word, character, or pixel is most likely to appear next, based on having analyzed vast data that came before.
3232

33-
You might ask, why not have it write all my code for me? Why do I even need tutorials like this one any more? There are caveats: It is easy to end up with faulty code, biased code, boring code.
33+
They do this so convincingly that they can even generate code. You might ask, why not have it write all my code for me? If it can do that, why do I even need tutorials like this one?
3434

35-
In this tutorial, we will walk through the process of creative coding with a code-writing AI text-generator. Along the way, we will share tips, warnings, and critical considerations about how we use AI. They will be flagged "Try This!" for tips, "Warning" for cautions, and "Critical Context" for mindful reflections.
35+
Well, there are caveats: It is far too easy to end up with faulty code, biased code, and boring code.
36+
37+
In this tutorial, we will walk through the process of p5.js-style creative coding Using a code-writing AI text-generator. Along the way, we will share tips, warnings, and critical considerations about how we use AI. These comments will be flagged "Try This!" for tips, "Warning" for cautions, and "Critical Context" for mindful reflections.
3638

3739
This tutorial is Part 1 in a series of four tutorials that focus on using AI creatively and thoughtfully. Feel free to adapt them for your own critical exploration of AI systems:
3840

@@ -46,7 +48,7 @@ This tutorial is Part 1 in a series of four tutorials that focus on using AI cre
4648

4749
Pick something you'd like to create with p5.js. Write down your idea for yourself, with as many details as you can imagine. Try to describe it in a few different ways: How does it look? What does it do? How does it work?
4850

49-
For this example, I chose a tutorial I haven't been able to find elsewhere:
51+
For this example, I chose to make something I imagined but that I haven't been able to find elsewhere. I'll write it as a basic prompt to GPT like this:
5052

5153
`Convert webcam video to a halftone look where the dot size is based on the darkness in that area of the image.`
5254

@@ -57,6 +59,8 @@ Keep the project scope small to start. Do you have different versions of the ide
5759

5860
`- Output as a GIF`
5961
`- Make 2-color halftone pixels instead of grayscale`
62+
63+
I may also find that as I code I think of more ideas.
6064
</Callout>
6165

6266
You can follow along with this example in the [p5.js Web Editor](https://editor.p5js.org/sarahciston/sketches/LiHcPXdv1), and you can also follow the [chat thread](https://chatgpt.com/share/67094820-dc28-8003-bd34-14cc1e7b4572) used to create it.
@@ -67,29 +71,39 @@ When will you choose to use GPT tools for your project, and when will you skip t
6771

6872
### Step 2. Gather your tools
6973

70-
Start by logging into your preferred chat-based AI tool. Some options include [OpenAI's ChatGPT](https://chat.openai.com), [Replit Ghostwriter](https://replit.com/), [Blackbox.ai](https://www.blackbox.ai/) — each of these have limited free access.
74+
Start by logging into your preferred chat-based AI tool. Some options include [OpenAI's ChatGPT](https://chat.openai.com), [Replit Ghostwriter](https://replit.com/), [Blackbox.ai](https://www.blackbox.ai/) — each of these have limited free access, but there is a lot you can do even with the free versions.
7175

7276
<Callout title="Warning">
73-
While some paid tiers use more advanced models compared to the free versions, you should still be able to create a strong project without spending any money. Make sure you are using a free tier if you don't want to be charged.
77+
Make sure you are using a free tier if you don't want to be charged. While some paid tiers use more advanced models compared to the free versions, you should still be able to create a strong project without spending any money.
7478
</Callout>
7579

7680
<Callout title="Critical Context">
7781
Unfortunately none of these AI tools are open-source, and (at the time of this writing) I don't know of any open-source or open-data AI tools for coding. These closed-source, proprietary tools often use data scraped from open-source platforms like GitHub in order to train their tools.
7882
</Callout>
7983

8084
<Callout>
81-
In addition to accessing these AI tools from their web interfaces, you can also use some of them from inside IDEs (coding programs like Microsoft Visual Studio) by downloading an extension or widget. This has advantages and disadvantages. For example, IDE widgets can offer autocomplete suggestions for you as you code. This may help you find a function name you want to use, but it can also overdetermine the direction of your project or steer you toward programming solutions that are incorrect or unhelpful. In other tutorials in this collection, we will use p5.js and API (Application Program Interface) of AI tools to create our own custom interface, which is a third option for using AI tools besides the web interfaces and IDE widgets.
85+
In addition to accessing these AI tools from their web interfaces, you can also use some of them from inside IDEs (coding programs like Microsoft Visual Studio) by downloading an extension or widget. This has advantages and disadvantages.
86+
87+
For example, IDE widgets can offer autocomplete suggestions for you as you code. This may help you find a function name you want to use, but it can also overdetermine the direction of your project. It might steer you toward programming solutions that are incorrect or unhelpful. In other tutorials in this collection, we will use p5.js and the APIs (Application Program Interfaces) of various AI tools to create our own custom interface, which is a third option for using AI tools besides the web interfaces and IDE widgets.
88+
89+
Learning to manipulate existing tools, or make our own tools, beyond the standard presets available? That's what p5.js is all about!
8290
</Callout>
8391

8492
<Callout title="Warning">
85-
Text-generating AI are created by scraping publicly available code from platforms like GitHub and StackOverflow. This means the generated code you'll output comes from other coders like you. So it is not perfect, it is not unique, and it is not guaranteed to work. And remember, if you are using Github along with these AI tools, you cannot protect your code from being scraped and used to train the next AI tool.
93+
Text-generating AI are created by scraping publicly available code from platforms like GitHub and StackOverflow. This means the generated code you'll output comes from other coders like you. So it is not perfect, it is not unique, and it is not guaranteed to work. And remember, if you are using Github along with these AI tools, it is very difficult to protect your own code from also being scraped and used to train the next AI tool.
8694
</Callout>
8795

8896
With all this in mind, once you've picked your tools, you can begin by prompting the same way you would a plaintext chat prompt. For this example, we are using the free plan for ChatGPT, running the GPT-4o model.
8997

9098
### Step 3. Prompt GPT to generate some p5.js code
9199

92-
Pause. Rather than prompting ChatGPT with your whole project idea at once, let's break it down into parts. It's okay if you don't know every part of the process you want to create — that's why we're asking for help. We do this to understand more about what we are trying to make, and so that we receive less generic code more tailored to our project. Don't forget to tell it we're coding in p5.js!
100+
Pause.
101+
102+
Rather than prompting ChatGPT with your whole project idea at once, let's break it down into parts. It's okay if you don't know every part of the process you want to create — that's why we're asking for help.
103+
104+
We do this to understand more about what we are trying to make, and so that we receive less generic code more tailored to our project.
105+
106+
Don't forget to tell it we're coding in p5.js!
93107

94108
`Help me code a project in p5.js. I'd like to describe features and then have them added please.`
95109
`- First, import webcam video`
@@ -110,9 +124,7 @@ Try writing the steps out in pseudocode, where you describe the steps of coding
110124

111125
<Callout>
112126
Type out, run, and compare the code at each step. This may also help you learn more about how the code works interactively, and give you new ideas to try.
113-
</Callout>
114127

115-
<Callout title="Warning">
116128
Review the answers it provides before you decide to use them. The code may include more advanced techniques than you know or than you actually need for your problem.
117129
</Callout>
118130

@@ -125,15 +137,13 @@ Also, its solution may not be the right solution for you. How does your pseudoco
125137
Bring the output code results into the p5.js Editor or your IDE of choice. Retype the code by hand; don't cut and paste if possible. This will help you make sure you understand it and that it fits into your project.
126138

127139
<Callout>
128-
Use your own knowledge to adapt it, and don't be afraid to rework it to suit your project's needs.
129-
</Callout>
140+
Don't assume it works. Use your own knowledge to adapt it, and don't be afraid to rework it to suit your project's needs.
130141

131-
<Callout title="Warning">
132-
Don't assume it works. It may not run the way you want it to; it may not run at all at first. Trust your coding skills and don't be afraid to tinker with it.
142+
It may not run the way you want it to; it may not run at all at first. Trust your coding skills and don't be afraid to tinker with it.
133143
</Callout>
134144

135145
<Callout title="Critical Context">
136-
Make sure to cite ChatGPT whenever you use it for writing code (or any other text). Include the date it was prompted and if possible the prompt. You can also include the version of the model if you know it and any other details relevant to how you used the system. This is helpful for future readers of your code who want to understand how you made it. Also, it is an important habit to cite any code or examples you draw from, human or otherwise, even if you end up rewriting the code.
146+
Make sure to cite ChatGPT and any other AI whenever you use them for writing code (or making any other creative work). Include the date it was prompted and if possible the prompt. You can also include the version of the model if you know it and any other details relevant to how you used the system. This is helpful for future readers of your code who want to understand how you made it. Also, it is an important habit to cite any code or examples you draw fromhuman or otherwise even if you end up rewriting the code.
137147
</Callout>
138148

139149
### Step 5. Ask follow-up questions
@@ -147,7 +157,7 @@ Generative AI can also help explain concepts in code you find elsewhere or can h
147157
It still may not have the right answer. Try asking about small sections. Try asking in different ways. Don't assume additional code or answers work either. Don't trust GPT more than yourself. Don't even trust it more than Wikipedia.
148158

149159
<Callout title="Critical Context">
150-
Be aware of bias, fairness, representation, as with all generated text. [One of the best ways to address bias is to] work with other people, not only bots. We're all fallible, but incorporating other perspectives helps us see the gaps in our thinking.
160+
Be aware of bias, fairness, representation, as with all generated text. One way to help address bias is to work with other people, not only bots. We're all fallible, but incorporating other perspectives helps us see the gaps in our thinking.
151161
</Callout>
152162

153163
### Step 6. Combine ChatGPT and your own capabilities to enhance your project
@@ -187,10 +197,10 @@ function draw() {
187197
```
188198

189199
<Callout title="Warning">
190-
Case in point: I noticed that when we added the two-color feature, GPT seemed to have lost the original request we gave it to make the pixels different sizes. In fact, the variation was very tiny because I had set grid size was small. Being able to read through the code and my prior conversation with the bot helped diagnose the problem and helped me find a solution I preferred. Watch out for things like this, and use your own coding abilities to combine the solutions it gives you into the actual solution you need.
200+
Case in point: GPT is fallible. I noticed that when we added the two-color feature, GPT seemed to have lost the original request we gave it to make the pixels different sizes. In fact, the variation was very tiny because I had set grid size was small. Being able to read through both the code and also my prior conversation with the bot helped diagnose the problem and helped me find a solution I preferred. Watch out for things like this, and use your own coding abilities to combine the solutions it gives you into the actual solution you need.
191201
</Callout>
192202

193-
Now let's add an additional feature, so we can output our videos as GIFs. Here ChatGPT actually gets it wrong, but p5.js has a simple [`saveGif()`](https://p5js.org/reference/p5/saveGif/) function built in. You can add this code at the bottom of your sketch:
203+
Now let's add an additional feature, so we can output our videos as GIFs. Here ChatGPT actually gets it wrong, offering complicated and ineffective code, but p5.js has a simple built-in function called [`saveGif()`](https://p5js.org/reference/p5/saveGif/). You can add this code at the bottom of your sketch:
194204

195205
```js
196206
function keyPressed() {
@@ -203,7 +213,7 @@ function keyPressed() {
203213
In this example, `s` is the key to press to save a GIF, `halftoneGif` is the name of your saved GIF and `3` is the number of seconds it will capture.
204214

205215
<Callout title="Critical context">
206-
Now that you have an example of ChatGPT-generated halftone videos, how does the result compare to the vision you imagined? How would you modify it to look more like you imagined, or build off what you have to create something new? How would solve this same problem in a different way?
216+
Now that you have an example of ChatGPT-generated halftone videos, how does the result compare to the vision you imagined? How would you modify it to look more like you imagined, or build off what you have to create something new? If you were writing this "from scratch" how would solve this same problem in a different way?
207217
</Callout>
208218

209219
<Callout>
@@ -212,15 +222,19 @@ Keep experimenting. Work modularly to put smaller pieces together into bigger pa
212222

213223
### Step 7. Try many different ways to interact with ChatGPT critically and creatively
214224

215-
Besides generating new code, you can use ChatGPT and tools like it to do lots of other things related to creative coding. In a study of how computer science students used ChatGPT, the most common tasks were to have it explain programming concepts that you'd like to understand better, or to have it give code examples to help illustrate those concepts (Ma 2024). It was also used to interpret error messages and for checking existing code to help you optimize, debug, or clarify a particular section.
225+
Besides generating new code, you can use ChatGPT and tools like it to do lots of other things related to creative coding. In a study of how computer science students used ChatGPT, the most common tasks were:
226+
* to have it explain programming concepts that you'd like to understand better
227+
* to have it give code examples to help illustrate those concepts
228+
229+
It was also used to interpret error messages and for checking existing code to help you optimize, debug, or clarify a particular section (Ma 2024).
216230

217231
For example, you might experiment with a prompt like: `Here is a piece of p5.js code. Please offer ideas for making it run more efficiently…` Then paste in your code.
218232

219-
The students also cautioned that "ChatGPT may not always give the correct answers or answers they needed, particularly in the context of programming, where multiple solutions exist" (Ma 2024, 6).
233+
The students in the study also cautioned that "ChatGPT may not always give the correct answers or answers they needed, particularly in the context of programming, where multiple solutions exist" (Ma 2024, 6).
220234

221235
### Step 8. Bonus: Use code generating as a creative springboard
222236

223-
Instead of prompting it to generate code, have it prompt you to code instead. Ask it for quick code exercises that can spark your imagination, or drills that help you practice your skills. Then you can create the code. For example:
237+
Instead of prompting GPT to generate code, have it prompt *you* to code instead. Ask it for quick code exercises that can spark your imagination, or drills that help you practice your skills. Then you create the code. For example:
224238

225239
`Please compose prompts for creative coding exercises using p5.js that help me learn about making web pages`
226240

@@ -232,19 +246,19 @@ Use code generators to help you be more creative and go deeper with coding, rath
232246

233247
### Critical use of AI in creative coding
234248

235-
This tutorial emphasized being mindful of generative AI as source material. We cannot assume it is correct, because it is gathered from millions of crowd-sourced pieces of text. Generative AI's biases are not flaws to be eventually optimized out; rather, the issues are fundamental components of how AI is designed.
249+
This tutorial emphasizes being mindful of generative AI as source material. We cannot assume AI is correct, because its results are gathered from millions of crowd-sourced pieces of text. Generative AI's biases are not flaws to be eventually optimized out; rather, the issues are fundamental components of how AI is designed.
236250

237-
This is similar to how we had to learn to read Wikipedia critically, rather than believing it worked like a regular encyclopedia. Just as you seek alternative sources when relying on Wikipedia, don't rely solely on ChatGPT for your programming or other kinds of information.
251+
This is similar to how we have learned to read Wikipedia critically, rather than believing it works like a traditional encyclopedia. Just as you seek additional, alternative sources when relying on Wikipedia, don't rely solely on ChatGPT for your programming or other kinds of information.
238252

239-
Generative AI can be a useful tool to help you learn quickly if you already have some basic coding skills. It may not be right for total beginners, and it shouldn't be used as anyone's only tool.
253+
Generative AI can be a useful tool to help you learn quickly if you already have some basic coding skills. It may not be right for total beginners, it won't replace the jobs of experts, and it shouldn't be used as anyone's only tool.
240254

241-
When you need something to “just work” — and you don't want to harm the environment — don't pull up ChatGPT, call a friend.
255+
When you need something to “just work” — and you don't want to harm the environment — don't pull up ChatGPT. Call a friend.
242256

243257
### What is 'critical' about Critical AI?
244258

245259
Critical does not mean negative, but thoughtful, adopting a variety of perspectives. Critical perspectives help us make technical and creative choices that match our values and our goals. They help us be mindful of and responsible for, and adaptable to the impacts.
246260

247-
Using AI critically means understanding more about where its outputs come from and how they are made. This will be part of learning practical skills for working with AI in each of these tutorials.
261+
Using AI critically means understanding more about where its outputs come from and how they are made. This is part of learning practical skills for working with AI in each of these tutorials.
248262

249263
It also means keeping in mind the impacts of AI, by understanding AI tools as part of complex systems that are both social and technical. AI also emphasizes specific concerns including data exploitation, labor exploitation, misinformation, discrimination, and environmental impacts (see Atairu 2024).
250264

0 commit comments

Comments
 (0)