3 ms·
I just used GPT-4 yesterday to write a Go-parser for a specific JSON input. Within two prompts it could read the JSON data from a stdin stream, unmarshal it to
by theshrike79 4y ago
I just used GPT-4 yesterday to write a Go-parser for a specific JSON input.
Within two prompts it could read the JSON data from a stdin stream, unmarshal it to Go structs and print the correct fields to stdout as a human-readable line of text.
Then I told it to colour the timestamp and id fields using the fatih/color -package, and it did it correctly.
In total it took me about 4-5 prompts to get where I wanted. I just needed to fine-tune the printing to stdout part a bit to get it just how I liked, but it saved me a ton of boring template code writing and iteration.
I could've done it easily myself, but there were a few fiddly bits that would've required me to look up the documentation to check the exact way to do things. GPT4 had it correct from the start.
Then I asked it to write unit tests for the code, and it confidently started writing correct-looking code that would take the same input and expect the correct output, but just stopped in the middle. Three times. I stopped trying.
And another case:
I tried to use GPT-3.5 to write me a program that would live-tail JSON-logs from Sumo Logic and pretty-print them to stdout. It confidently typed out completely correct code with API endpoints and all. ...except the endpoints didn't exist anymore, Sumo Logic in their great wisdom had removed them completely. The only solution is to use their 5 year old binary-only livetail executable.
GPT4 with the same input gave me a shell-script that starts a search job with the correct parameters and polls the endpoint that returns the result when it's done.
The speed at which this is developing is really fascinating, I'm not really afraid for my job but I do love how this will automate (some of) the boring stuff away a bit like GitHub CoPilot did, but better.
- pixl97 4y ago>Then I asked it to write unit tests for the code, and it confidently started writing correct-looking code that would take the same input and expect the correct output, but just stopped in the middle. One of two things. First ask it to continue. Sometimes it just stops half way thru code foe whatever reason. The other possibility is you filled up the token context window. Not much you can do but wait for the 32k model.
- theshrike79 4y agoI asked it to continue twice after the first failure. Every time it failed in about the same point. Might've filled up some mysterious limit in the model. I didn't really need the unit tests anyway, but I wanted to try if it could do it :)