GPT Chat Web Page

After avoiding front-end web development, I finally give in, I’m joining the party…well hopefully enough to be dangerous 🙂

I started with web development back in the IE 3 days. Nothing was compatible between browsers. The days of <blink> and scrolling marquees. Later I worked as an Internet Developer around the dot-com bust, using ASP with C++ COM objects, or a Perl CGI backend.

I’d also done some front-end in an ASP.NET role, or when building a few sites in Rails, and we did some cool stuff at a company called Industrial Software Solutions with XMLHttpRequest and ISAPI before AJAX had become main stream. But typically I avoided it like a wounded bear.

Since then, JavaScript has taken over the world, proving the saying yet again:

…the race is not to the swift, nor the battle to the strong, neither yet bread to the wise, nor yet riches to the intelligent, nor yet favour to men of knowledge; but time and chance happeneth to them all.

JavaScript is now everywhere and it’s about time I upgraded my web skills.

With that in mind, I followed this excellent tutorial on YouTube to build a JavaScript console:

And then modified it to call GPT Chat to answer questions. Keeping things simple, it just makes synchronous requests:

As per the video, you enter questions at the bottom, and then the console displays the question and answer. For anyone interested, the source code is available here.

You will need to sign up with Open AI and create an API Key. Once you get your key, assign it to the bearer variable in main.js:


You can change the other variables in main.js to affect the results produced by GPT.

Well, that was a fun small project, and I must say JavaScript has really come a long way!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s