I Coded Working AI in Scratch!
HTML-код
- Опубликовано: 9 фев 2025
- Not just a bunch of ifs and say blocks - this is real AI.
----
Scratch Profile: scratch.mit.ed...
Email: contact@donutask.com
Website: donutask.com
----
I can't publish this extension because it requires an API key. Here are the resources you need to create it yourself. The OpenAI API, ironically, requires real money to use.
Scratch mod used: sheeptester.gi...
OpenAI Documentation: platform.opena...
Get API Key (requires account and billing details): platform.opena...
JavaScript Code (You need to provide an API key):
class AIBlock {
getInfo() {
//Metadata for block
return {
"id": "AI",
"name": "AI",
"blocks": [{
"opcode": "completePrompt",
"blockType": "reporter",
"text": "complete prompt [string]",
"arguments": {
"string": {
"type": "string",
"defaultValue": "Explain quantum computing in simple terms"
}
}
}],
//don't worry about it
"menus": {}
};
}
async completePrompt({ string }) {
//Remove trailing spaces, required for model to work properly
const text = string.trim();
//Request text completion using Davinci3
const url = `api.openai.com...`;
const options = {
//Has to be post for some reason
method: "POST",
//Input prompt and a decent length
body: JSON.stringify({
prompt: text,
max_tokens: 300,
}),
//API key, and JSON content type
headers: {
Authorization: "Bearer " + API_KEY,
"Content-type": "application/json; charset=UTF-8"
},
};
console.log("REQUEST:" + url);
//Fetch and await promise.
const response = await fetch(url, options);
//Get JSON data
const jsonData = await response.json();
//The ai response will be the first (and only) choices text
const output = jsonData.choices[0].text;
return output;
}
}
//Register block with Scratch
Scratch.extensions.register(new AIBlock());
---
Sound effects from ZapSplat.com
Some images generated by DALL-E
Images and videos from Unsplash.com and Pexels.com
Music by Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 4.0 License
creativecommons...
Subscribe!
Oh, and if you want to support me financially, consider becoming a member :)
/ @donut_ask
I should've got AI to write the code!
Unfortunately, I can't publish the extension because it requires an API key that costs real money. If you have the money, the code (along with extra details) is in the description.
Anyways, thank you for watching :D
I loved the video!
@@ThirtyDimensionedMissile Thank you :)
@@donut_ask
No problem!
THAT IS WHAT I WAS TRYING TO DO 1 WEEK AGO
Cool video btw
Donutask: "this is the super secret api key im not allowed to share with anyone"
Also Donutask: *casually shows the api key to thousands of viewers*
🤪
hehehehe
@@donut_ask you changed it... right..?!?
@RealMadhuuthere are either two options: 1. he changed it 2. he casually waits for everyone to spend his money. LMFAO
@@IlliaZhdanov I deleted it. I was stupid enough to not know how to properly sync audio and video, but not THAT stupid
“This is the super secret api key I’m not allowed to share with anyone” hmmm ok I’ll definitely keep that a secret
Ei09GOCHMYjMvt5jcfTrT3B1bkFJcbRIZP5kMhRMghUG7bdJ
I can keep it a secret. I cant vouch for the people I tell it to though...
I was just about to comment that
You actually didnt built any ai , you just made scratch talk with an api...
Yeah, a lot of people have mentioned that. I might need to change the title a bit. But I don't know how to phrase it in any other interesting way :/
Yoo, this is the most underrated extension ever! (Btw i didnt payed for this donation but google technicaly did)
This is the first super thanks I got. Thank you!!
@@donut_ask You're welcome, you deserved it because you spent cash on the video, basically its a cash back by google.
omg wait czech people?! 😱
@@lejacobofficial If you cash back from google, the person you sent the money doesn't get it. Are you only 10? How could you even think things work like that?
@@dabbopabblo I think you misunderstood him.
And you used ChatGPT to create ChatGPT in Scratch!
I've actually made one in Snap! (A different programming language) it has a URL block inside and some libraries that can do posts and send headers to the internet. It's much easier than making an entire extension from blocks instead of Javascript!
Pretty impressive how you did it in Scratch though. That was awesome!
Didn't know snap could do that
@@donut_ask snap is basically scratch on steroids with slightly outdated ui
it has a more complex custom blocks system and has firstclass blocks, so you can pass blocks to blocks to, for example, map a list
man putting blocks to do stuff is harder than programming
are you my ai
What a journey! Amazing video :)
Thank you :)
As a JS programmer this was painful to watch
I am very sorry for you having to use JS. (Since you understand it i want to share something stupid i did. I was trying to access object properties with obj["choices"] instead of obj.choices. I think it works the other way in python, because python.
um actually as a mf ur dick is small 🤓🤓🤓🤓
javascript is the worst programming language in the world.
@@TheRealMangoDevWould you care to try Cobol. Or maybe something like Brain fuck or whitespace. Or maybe even PHP?
Im a scratcher
"This is the super secret api key that im not allowed to share with anyone" *proceeds to show it to 80k+ peaople*
Hehe
A couple months ago, I started making my first AI in Scratch. It was a dog with 2 tricks: Sit and Come. Last week, I coded another dog AI but this time it does a random trick and it starts off with a 1 in 100 chance to get the trick right, which I did with random numbers and lists. If it chooses a number other than 1, it will choose a random trick out of 3 tricks (Sit, Speak, and Come). It doesn't choose the trick it was told to do because that wouldn't make sense if it was doing the trick wrong.
😎
Bro worked hard on this , he deserves a like guys.
😀
@@donut_ask it dident work
@@Shadow-Silver-Edits wat ?
Scratch “programmer” trying javascript for the first time be like
I've used JS before on a couple websites. But JS is awful!
Could you make a longer, more precise and step-by-step guide that explains every tiny thing. That would be awesome and absolutely deserve a sub.
I should, but maybe on a second channel. The explanation oarts are where people click off :(
@@donut_ask Yeah true. Smart.
Yes that would be great, I really want to do that but I am just to dumm to understand it, a step by step guide would be nice
@@scullycraft4776 Yeah.
1:43
It says "Never gonna give you up"
That is a creative way to deter some people looking for your personal info...
Haha some people actually thought it was my actual info
@@donut_askwait what
those are hardcore hackers probably
they're willing to get rickrolled if it means
a possible chance for someone's information
0:13 BLUR BLUR BLUR THE API KEY NOW NOW BLUR IT BLUR IT BLUR IT BLUR IT
how is this man so underrated
yeah, he replies to every comment.
@@rahulpanchal87 ok?
Harsh
I have no idea
Fr
note: The AI used is not ChatGPT, it is text-davinci
Yes
This is just using an extension that goes into ChatGPT AI. That means this isn't working AI in Scratch, especially since you had to go to a totally different website to do so with an extension. I was expecting for a neural network to be coded literally with scratch blocks.
Yeah the title and thumbnail is a bit clickbait on this video. Unfortunately it works; this is one of my top performing videos. No one would watch "I Just Used an Extension that Goes into ChatGPT AI". In the first 30 seconds, I clarify that this is an extension, so I'm not trying to waste your time. I hope you understand :)
Also, you can make a basic neural network in Scratch. But the most complex you can really do is recognise numbers. Predictive text would be impossible in regular scratch.
@@donut_ask Hey, it's all good, I understand that! I tried making a neural network in Spanish before lol
This is not coded AI in scratch, this is coded API.
Correct
@@donut_ask Implemented, false title.
ive been watching you since 1K subs! Good to see you finally get the attention you deserve.
Thank you
most underrated programmer in the game!!!!!!!!!!!!!!!!!!!!
flappy mack
He may be a good JavaScript programmer, but the title of this video still pisses me off
Yesterday I just got my AI to work in Scratch from scratch, it uses neural networks and you can talk to it.
So I guess I am quite talented. But nice video!
Link? Proof?
I probably will make a video of it on another RUclips channel, but I will not share a link yet, since I don't want it to be copied.
@@nitrous000 Hello! Here is a video of the usage with the AI: ruclips.net/video/po2Gu-5u7Kk/видео.html
This is very cool! Can you make step-by-step instructions through the process? also, can I use Google Gemini/Bard? can I publish the working ai? It would be very cool if it works and I hope you can make a longer video of this!
The griffpatch we didn't know we needed
the secret to coding nowawdays, is pasting your errors into chatgpt, and explaining what you want.
All you woulda had to do is copy your error from scratch, paste it into chatgpt, and say "make my scratch code block wor.. here is my error [paste error]. [Explain what you are doing]
it will fix your code. But also tell you what the error you have means incase you need to fix it again.
5:08
Donutask: “here is the super-secret API key that im not allowed to share with ANYONE.”
Also Donutask: *SHARING THE DAM SCREEN FOR THE API KEY*
That donutask guy sure is stupid!
1:42 no way you just did that. I was about to warn you about you not blurring it properly. 😂
Woohoo! AI in scratch.
🤖
6:08 “Good thing I have this time-altering thing!”
**pulls out ADHD toy**
tbh i have that exact toy
Just subscribed because like all there is right now is griffpatch this guy is so underrated
Thanks for putting me in the same sentence as the goat :)
This man is one of the few people who can genuinely make me laugh. You just earned a new subscriber! 😂😂😂
Thank you :D
@kramsdell_ no
Looks nice! Im glad I could answer you even in Scratch!
Can you answer my question?
@@omichall Of course! Please feel free to ask me any question you have, and I'll do my best to provide a helpful answer.
You're fake goner.
@@NotOmichall are you seriously chatgpt?
nice, i even tried it myself and it works! I kinda had to fix it by putting the api key code and use chatgpt to fix further cuz it no work and thanks to fixes it worked but i also found out u dont need money to get api key, i dont care about limits
How did you get it for free?
@@donut_ask easy
generating api key requires no money
i simply opened the link, clicked the button that generates the key, BOOM, key generated, just a reminder i DO have an openai account
That's cool and all but I once made an apple go to a random position when you click it
that's cool and all but once I made an apple move right when you pressed left
Are both of you dumb both of those things are 10x worse
First time on the channel... I love it!
👋 Hello, and thank you :)
@@donut_ask You're welcome.
Same
Ive been here since 1K! I submitted a game for playing your scratch games too i also remember i made a remix of your finding game thing you used
thanks :)
i'm usually a Python programmer, but i've had some JS experience, so i can try to breakdown the thought process here, but forgive some estimation
"POST" is a form of HTTP interfacing, instead of asking the server (OpenAI) "hey, can we get this resource", it's like putting a little request form in an envelope and putting it in a queue for OpenAI! JavaScript's JSON is a library(ish? i'm not sure on terminology for JavaScript) that essentially takes a few tidbits of information (like the prompt and max_tokens), similar to a dictionary in Python, or, good lord, Objects in JavaScript. a mere google search gave me shivers.
other than that, the headers are just ways for the content to be delivered to OpenAI's HTTP servers.
after that, the request is sent, and async/await allows JavaScript to keep working with other functions and elements without having to wait for one element to finish.
then, the response is a JSON data packet, which is then accessing the choices element in the JSON, choosing the first, and giving you a string as an output!
finally, the actual elements come together in a neat little package, registering the block in Scratch.
Great explanation!! If only I could of said it like this in the video
JSON is a data format
“In Scratch”
Also I would love to run this in Snap. I can surely modify this…
I've never used snap, good luck
I feel like there is a way to make almost good working chat AI, but it's also possible to make regular Nextbot-like AI.
Underrated creator spotted 👀
:)
Just wait until someone makes a working ai using only scratch blocks
Next Griffpatch project...
already did :) of course, it's not perfect in any way, nor can you call it an actual a.i, but the concept is the same as an a.i would.
it will be mack
wow great video man
Thanks
@@donut_ask also make your thumbnails more mr beast like, add suprised faces to them
😱😱😱😱😱😱
@@donut_ask negro coton picker
@@donut_ask mb bro
I actually made one in Vanilla Scratch! Using cloud variables. It was interesting. My classmates and teachers liked the little project.
Oooh, clever!
Can you give me the link? I WANT IT.
I dare you too make the most cursed game ever
I TRIPLE DOG DARE YOU
WITH A CHARY ON TOP
Maybe
I Love Keyboard-Typed Coding More Than Block Coding
Same
@@donut_ask 2 people who like the same thing as me, I guess my js and java(and lots of languages) classes definitely made me a genius
@@thekeyboardwarrior1018 Everybody Loves Text-Based Programming Languages More Than Block-Based Programming Languages
@@thekeyboardwarrior1018 Scheme Programming Language, C# Programming Language, XNA Programming Language and XML Programming Language are My Favorites
@@cyancaelus6456 yeah
Ever since i watched polymars, he was terrible. But when i saw your video, you became my number scratch youtuber in the world.
i managed to read the card info but it was a rick roll but idk if the card number is real so maybe try blurring it more if it is
Card number is fake, don't worry I'm only a little stupid- not that much!
You are so underrated on yt. You definitely deseeve over 500 k subs
😀
5:07
Him: I can't show this code to anyone
Me: ...
...
…
...
I used your clicker tutorial and it worked-¹!except sunshine and the water) you just earned a sub for helping scratchers
Thanks :)
The Gandi IDE already has an AI extension, you can give it a try 😊
That sounds cool
This is honestly pretty cool!
thanks
@@donut_ask no problem!
@@donut_ask no problem
Amazing! I am very curious about your family environment that grow up you as professional engineer such as programming, talking and kindness!
Keep trying!
Just so you know, these aren't scratch clones, they are actually scratch, just forked and modified a bit, please use Turbowarp by the way
Yes they are just forks. I will use turbo warp next time, didn't know about it doing custom extensions before.
1:51 I don't even know much about coding and making games. but this experience is too real for me.
4:37 Ah yes, my favorite programming language: Srachahahaccci
This is really cool and keep up the good work.
Thanks :)
title: i coded working ai in scratch
video: im using this random persons version of scratch
Donutask is such a stupid liar!
Aw. Thanks! It helps a lot!
ScratchGPT by DonutAI
"How to make a scratch game with 1 block" step 1. Do what he did and create your own block
Next video: I MADE AN ENTIRE GAME INONE BLOCK!!!!
@@donut_ask … NO WAY I GOT HEARTED BY THE FAMOUS RUclipsR AND THANK YOU FOR MAKING THAT THE NEXT VIDEO!!
Thats so cool love it
Thanks :)
At 5:40
Line 34 | "method: 'post'"
POST is a type to pass info to php, in that case, basically it will get the input from the Scratch and send it to the php of the AI
I could be wrong, but I think that is it
Seems about right
I'M BACK ON RUclips
LET'S GO!
@@donut_ask YESSSSSSSSSSSS
Woohoo, youre so good at coding!
Thanks
If you could actually share this, this would go on trend. 💀💀
my brain hurts this is too smart-y🥶🥶
This is me > 🤓🤓
Imagine someone wants to see in description talk Scratch OpenAI CGPT, but there is no actual link, or link on the charlesbel's games. There is no ChatGPT in here, it's just a challenge.
Task: become donut
🍩
Love it!
now make a transistor simulator and make a whole ai out of simulated transistors
Video Idea: Google in Scratch
Now make it entirely in Scratch lol
Don't think that's possible. Bet Griffpatch will do it though.
@@donut_ask I mean, people have already coded working neural networks that recognize drawn text, but we havent reached chatgpt level lol
Yeah, there's a big difference
here before this donut blows up
🍩💣
6:09 Это вообще-то головоломка (она есть у меня дома) (я пишу с аккаунта моей мамы)
I'm turning this into an extension that can be used on Turbowarp (by editing a few things)
Yay
"thIS IS A SUPer SEcret API key"
5:11 you said you can't share it with anyone but you are sharing it with 23K people
🤔
@@donut_ask The API key
I Love Syntax Coding More Than Scratch Coding
the extension system will be pushed hard on 3d projects
Me: How many times did yoy reply random comment?
Donutask: Yes
No, I don't ever reply to comments
what’s funny is that robot sprite in the beginning reminds me of those 60s sci-fi film with crazy cool predictions on the future, definitely a true future with advanced AI like this
Amazing!!!🤯
real chads would us scratchattach.
you offended whole scratch community (and me) by calling sheeptester a random person. They made 2 awsome scratch websites that helped during the early scratch 3 era
I actually never heard of them before lol
@@donut_ask they made htmlflyer (I probably spelt that wrong) that made html website file/s and it even worked with custom stuff from the same scratch mod you were using but now turbowarp is popular because its just better and it has a built in html converter plus you can also easily export to Windows mac and Linux. Also seeing alot of small creators recently keep it up!
Sheeptester isn't a random person they make so much epic stuff 😩 🙃🥺😶
I didn't know 😕
use GPT-2 so you dont have to spend money on usage limits
Scratch MUST hire this man
you could've uploaded it to pastebin or something instead of pasting the code in the description.
Here you go: pastebin.com/2zkK5Tfd
@@donut_ask tyty!
back after a long time, i bought a Paid Account for open ai, i should be able to create it now
Yay!
It keeps on saying TypeError and i don't understand.
2:00 Me When A Brain Freeze Happens:
AhhhhhhHHHHHHHHHhhhHhHHhh
@@donut_ask Yeah Lol
now do it without time-altering device in your pocket
Impossible
THAT IS WHAT I WAS TRYING TO DO 1 WEEK AGO
How did you go with it?
@@donut_ask Lol, i made it so it can say anything you want it to say, and made it smile and mad
@@donut_ask Its hard
"random person"
dude, that's griffpatch
Who's griffpatch
oh hes basically the most famous person on scratch
@@jehonasahitibejta920 r/wooosh
MY BRAIN IS IN PRAINNNNNNNNNNNN
real footage of a 8 year old coding and cracking jokes.
it cant read the zero at the end
2:44 timing is perfect
How did I manage to mess this up!
wait so are the scratch sprites now sentient 😲😲
Oh no
*_A-_*