Updating the JS 3

Tom Chant
InstructorTom Chant
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

This lesson involves updating JavaScript code for testing. Changes include switching from push to concatenate strings, adjusting variables, and storing completions differently. Testing produces expected but incomplete and unrelated output. Increasing the "max tokens" parameter is suggested but may lead to long, irrelevant responses. The lesson emphasizes troubleshooting and basic code adjustments before addressing deeper issues in the next step.

[00:00] we need to make a few more changes to the JavaScript before we can do some testing. So at the moment, in these two commented lines of code, we are pushing to the old conversation array, and we're also sending our completion to render typewriter text. Those two lines of code are not going to work anymore.

[00:18] We need to make some changes. So firstly, let's uncomment this line of code, and we'll change this to conversation string. And instead of using push, we will, of course, use plus equals. And what is it that we need to update conversation string with?

[00:35] Well, I've just pasted in the response that we got up here, and it's pretty similar to the responses we were getting when we were using the chat GPT models. Now, if we look down here, this one ends with messages. Messages doesn't exist. We've got choices,

[00:51] but the completion is actually stored in text. So let's just change message for text. And of course, we don't need these brackets. And now that we're updating conversation string just with the completion, we can actually reuse this code here because we also need to send the completion

[01:10] to render typewriter text. So let's just paste that in here, and now it should work. So I'm just going to delete a couple of console.logs. And let's delete all of this ugly code as well and give it a test. And okay, it's working. And it said, I've got some lovely things for sale in my shop.

[01:32] I hope you like. Now, the reason why it's finished on like with no punctuation is because now we're using a DaVinci model again. We need to set max tokens. At the moment, it is set to 16 by default. Let's set it to something much higher. And I'm just going to try that again.

[01:55] Wow, and now it's gone a little bit crazy. All I said was, hey there. And it's given us all of this stuff, which is sort of related to the data we uploaded. It certainly got the email address right. And it's given us some rather random phone numbers. Although this one is not too far away

[02:14] from the one we told it about. And then it starts going on about using cookies on the website. Well, this is more than just hallucination. It's actually gone a bit crazy. And what's worse is that it still didn't finish on a complete sentence. So if we whacked max tokens up to something much higher, like a thousand, I've got a feeling

[02:32] that this crazy chatbot would go on and on. But hey-ho, at least it's working. The basic mechanics are fine. So in the next scrim, let's start figuring out what's going wrong.

egghead
egghead
~ 41 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today