I Coded Working AI in Scratch!
HTML-код
- Опубликовано: 21 апр 2023
- Not just a bunch of ifs and say blocks - this is real AI.
----
Scratch Profile: scratch.mit.edu/users/charles...
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.github.io/scratch...
OpenAI Documentation: platform.openai.com/docs/api-...
Get API Key (requires account and billing details): platform.openai.com/account/a...
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/v1/engines/tex...`;
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.org/licenses/b...
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
ive been watching you since 1K subs! Good to see you finally get the attention you deserve.
Thank you
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
note: The AI used is not ChatGPT, it is text-davinci
Yes
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
And you used ChatGPT to create ChatGPT in Scratch!
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 :)
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 :)
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.
First time on the channel... I love it!
👋 Hello, and thank you :)
@@donut_ask You're welcome.
Same
This man is one of the few people who can genuinely make me laugh. You just earned a new subscriber! 😂😂😂
Thank you :D
@@donut_ask was the api key at the end real
@@kramsdell_ no
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.
😎
i don't think thats an ai
What Website Did You Use For The "Data: URI Generator"?
Can't remember, i think it was just the top google result for 'Data URI Generator'
The griffpatch we didn't know we needed
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?
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.
@@nitrous69 Hello! Here is a video of the usage with the AI: ruclips.net/video/po2Gu-5u7Kk/видео.html
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
1:42 no way you just did that. I was about to warn you about you not blurring it properly. 😂
"This is the super secret api key that im not allowed to share with anyone" *proceeds to show it to 80k+ peaople*
Hehe
Amazing! I am very curious about your family environment that grow up you as professional engineer such as programming, talking and kindness!
Keep trying!
Love it!
Thats so cool love it
Thanks :)
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!
Bro worked hard on this , he deserves a like guys.
😀
@@donut_ask it dident work
@@影-銀 wat ?
most underrated programmer in the game!!!!!!!!!!!!!!!!!!!!
flappy mack
You are so underrated on yt. You definitely deseeve over 500 k subs
😀
I used your clicker tutorial and it worked-¹!except sunshine and the water) you just earned a sub for helping scratchers
Thanks :)
How do I create an API key, I don't understand what you said in the description
help.openai.com/en/articles/4936850-where-do-i-find-my-secret-api-key
Will it work when shared?
how did you get that url ?
Amazing!!!🤯
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.
Aw. Thanks! It helps a lot!
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.
can you give me the link of the ai assistant
This is honestly pretty cool!
thanks
@@donut_ask no problem!
@@donut_ask no problem
how can i make this extension?
This is really cool and keep up the good work.
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
Underrated creator spotted 👀
:)
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
Please how do I contact would love to discuss something on scratch Program with you
Email in description :)
I pasted the link but the chat gpt didn't work, can you give a link to the sb3 file via google drive mega or whatever
You need to get an API key for it to work
It keeps on saying TypeError and i don't understand.
Woohoo! AI in scratch.
🤖
I have that thingy too. Why haven't I tried to alter time with it?
Be careful not to break the space time continuum!
how is this man so underrated
yeah, he replies to every comment.
@@rahulpanchal87 ok?
Harsh
I have no idea
Fr
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
The Gandi IDE already has an AI extension, you can give it a try 😊
That sounds cool
Could you perhaps write the code, with the api key place saying "API-KEY"
Code is in description
whats the url?
/
WOW NICE VID!!! your literally a genius in scratch. Your channel is underrated it needs more subscribers!!! and hehe. I love how you put some jokes in your vids!
Thanks. I try to make boring videos actually fun to watch. Glad you liked it.
@@donut_ask i tried it, but i got an error :(
whats the url?
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
Woohoo, youre so good at coding!
Thanks
“In Scratch”
Also I would love to run this in Snap. I can surely modify this…
I've never used snap, good luck
i just got rick rolled, trying to steal someones credit card number. that makes me wonder if that card number is valid
I used a fake number generator. But you got RICK ROLLED!!!!!
what is the URL of this chat gpt extensions
I literally can't share it, sorry
Scratch “programmer” trying javascript for the first time be like
I've used JS before on a couple websites. But JS is awful!
This is not coded AI in scratch, this is coded API.
Correct
@@donut_ask Implemented, false title.
it cant read the zero at the end
Nice video
Thank you
please add the link to the working A.I in the description
I literally can't
my brain hurts this is too smart-y🥶🥶
This is me > 🤓🤓
title: i coded working ai in scratch
video: im using this random persons version of scratch
Donutask is such a stupid liar!
I'm turning this into an extension that can be used on Turbowarp (by editing a few things)
Yay
Amazing
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 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.
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
How do I paste the code into the scratch mod?
bagpipes
Yo, a few questions, one the code doesn't work, and two can i make a vid on this?
Do you have an API key? Or my code just sucks. You can make a video :)
@@donut_ask yea i got an api key
u are so good
Thanks :)
how do i set it up with the js?
See description. Unfortunately the API will cost money
@@donut_ask It does not say how to import it.
Could you upload the project so we can use the chatgpt block?
No, you can't upload projects with custom extensions
@@donut_ask 😭😭😭😭😭😭😭
1:51 I don't even know much about coding and making games. but this experience is too real for me.
now make a transistor simulator and make a whole ai out of simulated transistors
Task: become donut
🍩
6:08 “Good thing I have this time-altering thing!”
**pulls out ADHD toy**
tbh i have that exact toy
here before this donut blows up
🍩💣
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 :/
4:37 Ah yes, my favorite programming language: Srachahahaccci
real chads would us scratchattach.
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!
has anybody uploaded this?
probably
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
it dosent show the extension
It's not released
Why did you show the API key you werent meant to show?
I deleted it. I left it in the video because it would be funny
WHat is that programm at 5:36 ?
What program?
@@donut_ask At 5:36
For the code
so this is just scratch with chatgpt plugin?
Yes, I made an extension that adds a block which uses the openai api
5:07
Him: I can't show this code to anyone
Me: ...
...
…
...
scratch GOAT
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
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.
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.
how download
Can't.
So ive got the API and ive got the block, but everything i try, it keeps on saying API_KEY is not defined, can someone help? im an complete idiot when it comes to this lol.
Replace the word API_KEY in the code with your api key
yea i found that out before the reply, but then it says it cannot reconize sk (the start of my api key) so yea thats another problem.@@donut_ask
did you put "quotes" around it?
@@donut_ask no
just tried that out, now its giving me an error like: Cannot read properties of Undefined (reading '0'). yea codings frickin hard man-@@donut_ask