Updating the JS 1

Tom Chant
InstructorTom Chant
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

In this lesson, we learn about updating existing code to work with a fine-tuned DaVinci base model. We start by changing the conversation array to a conversation string, as DaVinci models only require a string for the conversation. We also update the push method to append the user's input to the conversation string.

However, we encounter a type error and realize that we need to change the const declaration to let. After resolving this issue, we successfully update the code. This lesson introduces us to the process of adapting code for a specific model and highlights the importance of understanding the model's requirements.

[00:00] Okay, so to use this model, we need to update our existing code. The first thing to remember here is that we have fine-tuned a DaVinci base model, and at the time of recording, you can't fine-tune GPT-4. That means that we need to get rid of loads of this specific format. Now, I've divided this process into several parts,

[00:19] and we'll have challenges for them over several scrims. The first task is to change this array, which is holding the conversation. DaVinci models just need a string holding the conversation, and we won't be using an instruction. Here are two mini challenges to do just that.

[00:36] Firstly, change conversation array to conversation string, and you can initialize it to an empty string. Now, I've just put a warning here. Think about how this is going to work. Is there any other change you need to make? I'm just going to let you think about that. Once you've done that, you can come down here

[00:54] and update conversation string with just the user's input. So, instead of pushing this whole object, all we actually want to push is whatever the user has inputted. Then, you can just log out conversation string to check it's working, and I've disabled the fetch reply function,

[01:11] as at the moment, we just get an error if we sent off the string instead of the array of objects to the current endpoint that we've got in our code right here. Okay, pause now, take all the time you need, and I'll see you back here in just a moment. Okay, hopefully, you managed to do that just fine. So, let's just delete everything we've got here.

[01:37] We're going to make this conversation string. I'm just using the abbreviation str, and we'll initialize that to an empty string. Next, we need to come down here and update conversation string with just the user's input. So, again, we need to convert conversation array to conversation string, and instead of push, we can just use plus equals,

[02:01] and let's log out conversation string and hit save. Okay, I'll just type something in the box, and look, we get an error, and it's a type error assignment to constant variable. Well, I did warn you here, think about how this is going to work. Is there any other change you need to make? Well, yes, we need to change this const for a let.

[02:22] Let's try again, and there we are. It is working. So, that is two of the jobs off the list. Let's move on to what happens inside the fetch reply function.

egghead
egghead
~ 8 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