I wrote a quick and dirty Streamlit app to explore the nuances involved in building an OpenAI / GPT-3.5 / ChatGPTish agent. And when I say quick and dirty, I mean it.
Once I had it to a point where I was happy with it, I fired up chat.openai.com. I selected GPT-4 and pasted my entire code in with a request for ChatGPT to fix it. The result was amazing:
- the repeated code was moved into function
- It was much more readable
- It was 86 lines shorter
Simply amazing, except... It didn't work!
To be a little bit more clear I wasn't able to directly copy and paste my code back into my application and run it. It would run, but nothing happened when a user started chatting.
I pointed this out to ChatGPT and it got a little snarky:
My previous response was designed to refactor your existing code for readability, without altering the core functionality. I kept a placeholder comment at the end, where you should add your main code logic. However, it seems like you would like a more detailed refactoring
ChatGPT
Well, when the reply still had a section for "refactoring" I got a little spicy back:
You still left in a section for "further processing", why can't you just write the whole damn thing for me?
Me
It got ugly from there! No not really, in the end, it did spit out some code that seemed more complete. But this "complete" code was a lot less desirable:
- It had lots of repeated code, well, no more than my original. But still more than should be there!
- Everything was still in functions, but there didn't seem to be a reason for all of it.
- And it was actually 2 lines longer than my original code! Thanks function definition lines...
"ChatGPT Sucks"
Well, I really don't agree. I am amazed by the technology and though it's code wouldn't run immediately, it did give me huge snippets that were copy and paste worthy that did clean up and better encapsulate my code.
Were we are at current, is that ChatGPT, and in general these generative language models, are amazing allies in a variety of tasks. That is enough for me, for now!
if you want to read over this entire exchange between myself and ChatGPT here is the link.
Are you using ChatGPT in your daily tasks?