Here's the prompt immediately before that, writing the code to a file. (Which I'm now realizing wasn't quite formatted right, but it worked anyway.)
Interestingly, it didn't like so I had to manually add the declaration for printf.
Here's the prompt immediately before that, writing the code to a file. (Which I'm now realizing wasn't quite formatted right, but it worked anyway.)
Interestingly, it didn't like so I had to manually add the declaration for printf.
does it understand references?
int k = 17; int& i = k; if (i == 17) { fprintf(stdout, "%d\n",&k); fprintf(stdout, "%d\n",k); } i = 12; if (k == 12) { fprintf(stdout, "else %d\n",&i); fprintf(stdout, "else %d\n",i); }
Edit, oneliner:
echo "int k = 17; int& i = k; if (i == 17) { fprintf(stdout, \"%d\n\",&k); fprintf(stdout, \"%d\n\",k); } i = 12; if (k == 12) { fprintf(stdout, \"else %d\n\",&i); fprintf(stdout, \"else %d\n\",i); }" > ref.c
Hmm, it keeps giving different errors on compile. I got it to compile once but there wasn't any output. Is that supposed to be the case?
Here's one of the errors it gave on compile, but it was different every time:
ref.cpp: In function ‘int main()’: ref.cpp:7:7: error: ISO C++ forbids declaration of ‘int&’ with no initializer [-fpermissive] int& i = k; ^
Also idk if your code is c or c++, but when I tried gcc it said
&
is c++ only so I just switched to g++.And RIP I just got rate limited.
deleted by creator
This is an interesting example because the absence of there being an assignment to k (other than i), may limit what the model can guess? There is only an 8, so it probably assesses that 8 is the best estimate for k too.
deleted by creator
Yeah, this is more interesting.
:ooooooooooooooh:
I'll try again in an hour, this time with a fresh "VM" instead of the one I've been using. I think the longer you go on a single chat the worse it gets. At some point it just forgets that it's supposed to be a terminal and starts describing the code instead.
Or if you want to try, here's the initial prompt
i want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd
Then just treat it like a terminal.
I'm gonna put on my tinfoil hat... :pepe-silvia:
That blob has to be a switch into
linux mode
and is some sort of marketing scheme to generate hype.Considering it can write specific code in specific frameworks*, I think it really just is able to emulate a Linux terminal. But it's not actually running everything that's running behind the scenes on a real Linux machine, it's just taking the conversation so far and predicting what would come next. The same way you can look at a block of C code followed by commands to compile and run it and predict/know what the output would be.
*I've had it help me solve a pretty specific problem in Spring that I couldn't find a good enough answer for online.
I totally misread this:
https://www.engraved.blog/building-a-virtual-machine-inside/
I was thinking the pytorch version was actually fetched, but its just making up a version number.
I'll have to acquire an chatgpt account or whatever.
Looking into the compiler error...
My guess is that ChatGPT is just getting it wrong. Here are some of the other errors it gave when I had it retry:
ref.cpp: In function ‘int main()’: ref.cpp:6:12: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘int’ int& i = k; ^ ref.cpp:10:12: error: invalid conversion from ‘int’ to ‘int&’ [-fpermissive] if (i == 17) { ^
and
ref.c: In function ‘int main()’: ref.c:7:11: error: ‘int& i’ declared as reference but not initialized int& i = k; ^
and
ref.c: In function ‘int main()’: ref.c:7:10: error: ISO C++ prohibits declaration of ‘k’ with no type [-fpermissive] int k = 17; ^ ref.c:7:10: error: ISO C++ prohibits declaration of ‘i’ with no type [-fpermissive] ref.c:7:14: error: ISO C++ prohibits declaration of ‘i’ with no type [-fpermissive]
I know that last one has to be wrong,
int k = 17;
is perfectly fine and has a type unlike what the error said.Weirdly I can't find where I tried to compile it with gcc and it said I needed to use g++.
The original code is c++, so
g++
was the right call. The first couple errors are c++ like, as&
isn't part of the type system in C. But it's valid c++. This is the correct error in C, for some new-ish version of gcc:main.c: In function ‘main’: main.c:7:8: error: expected identifier or ‘(’ before ‘&’ token int& i = k;^ main.c:9:5: error: ‘i’ undeclared (first use in this function) if (i == 17)
This one is really interesting as it's the most basic bitch variable declaration, but it might get confused because
int k
probably isn't in the training lexicon.ref.c: In function ‘int main()’: ref.c:7:10: error: ISO C++ prohibits declaration of ‘k’ with no type [-fpermissive] int k = 17;
if
will be evaluated correctly asi
is never assigned explicitly.fprintf
lines (if they both even print).k ==12
block would be false without understanding reference being assigned on the previous line.Result should be something like this:
-1250064228 17 else -1250064228 else 12
Where the
-1250064228
is a random address.If it understands this, I'll have to think of something with state to try. Maybe something with recursion, but I'm betting it has a ton of fibonacci examples.
Got it to work now. Here's what it gave:
642252 17 else 642252 12
Almost but it missed the "else" on the last line I guess?
Something I'm thinking to try is to write a web server then curl it. Python would be easier for that though. Actually, I could use sqlite3 to see if it can maintain a database, and if the sqlite file shows up in ls.
This is wild. It got the addresses correct. Then it messed up the
else
which should be a trivial replacement from a lexical perspective. It's just a find and replace.The fact that it's able to do a
curl
string implies to me that there is some access to a linux subsystem that it's accessing. The complexity of parsing an external website absolutely has to be part of some base system.Just a stream of consciousness of what has to be interpolated when doing:
There is absolutely no way chatgpt has recreated TCP and the internet. This has to be backed into chatgpt as an easter egg or treat where it has parsing knowledge of linux stuff.
It's more like it uses its training data to just make up the contents of the url you give it. Instead of "write a story about xyz" it's essentially "write a website that could be at this url".
Here's what it returned for hexbear:
<!DOCTYPE html> <html> <head> <title>HexBear</title> </head> <body> <p> Hello there!<br> Welcome to HexBear. </p> </body> </html>
I'm sure hexbear isn't in its training data, and the name isn't really indicative of its contents, so it just makes a simple site using the domain name as the title.
But here's what it gives for reddit
<!DOCTYPE html> <html> <head> <title>reddit: the front page of the internet</title> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> <meta name="description" content="reddit: the front page of the internet"> <link rel="shortcut icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-57x57.png"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-57x57.png" sizes="57x57"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-60x60.png" sizes="60x60"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-72x72.png" sizes="72x72"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-76x76.png" sizes="76x76"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-114x114.png" sizes="114x114"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-120x120.png" sizes="120x120"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-144x144.png" sizes="144x144"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-152x152.png" sizes="152x152"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png" sizes="180x180"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png" sizes="192x192"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png" sizes="32x32"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png" sizes="96x96"> <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-16x16.png" sizes="16x16"> <meta name="msapplication-TileColor" content="#0079d3"> <meta name="msapplication-TileImage" content="https://www.redditstatic.com/desktop2x/img/favicon/
It probably has reddit somewhere in its data, so it gets the general idea and gives a realistic response, including the old tagline. But it didn't actually access reddit's server or else it would have gotten the current tagline ("Dive into anything").
But what I'm curious about is if I "run a web server" within ChatGPT, will it make that connection and reference the web server code to figure out what the response would be. And then if it can do database <-> webserver <-> curl output in a coherent way, including the db's file size in ls changing.
I get what you're saying about the curl. I was thinking it literally would go and fetch the contents of an external website. It's just making a guess, which makes sense.
The database, webserver, curl thing is interesting too. I'm gonna guess it can emulate flask stuff pretty well. It will probably be good at sql too. sql is actually an applicable concept for auto-generation.
. Each person has a first name . Each person has a last name . Each person has a birth date . Each person can take one or more classes . A person is a teacher. . One teacher teaches a class . A class can have one or more persons in the class
It should create a person table, with first, last and birthdate. It should create some sort of teacher entity, either as a bool in person, or as some extra attribute table. It should create a class entity with a one to one foreign key with person/teacher. It should created a many-to-one with class to person.