Updating the JS 2

Tom Chant
InstructorTom Chant
Share this video with your friends

Social Share Links

Send Tweet
Published a year ago
Updated a year ago

The goal is to update the code by replacing the "CreateChatCompletion" endpoint with "CreateCompletion" and swapping out the "GPT-4" model with a fine-tuned model.

You'll need to change property names, test the endpoint, and ensure the API call to the new model works. Subsequent steps involve modifying two specific lines of code to advance the chatbot's development.

[00:00] Next up we need to change the endpoint. CreateChatCompletion is specific to models like GPT-4. We are going back to the completions endpoint which uses CreateCompletion. So I'm just going to come in here and delete chat.

[00:14] Now for your challenge I want you to swap out the model GPT-4 for your fine-tuned model. And you can get the model name from right at the end of the fine-tune process. Now if you've closed your terminal window don't worry, log in to OpenAI, go to the playground,

[00:31] come up here to where we've got model and just click this down arrow. That will bring up a list of all the regular models and also all of the fine-tuned models that you have created. Now for the second part of the challenge our fine-tuned model needs a property called prompt not messages.

[00:49] So you just need to swap out messages for prompt. And you also need to update this reference to conversation array. Conversation array does not exist anymore. Once you've done that you can run a test by logging out the response. Now before you do the challenge I'm just going to uncomment this fetch reply function call.

[01:08] And I have already commented out these two lines of code. When we've got the endpoint working properly we'll uncomment them and make some adjustments. Okay pause now, get this challenge sorted and I'll see you back here in just a moment. Okay hopefully you managed to do that just fine.

[01:30] So I'm going to come down here and I'm going to just grab the name of my fine-tuned model. And I've got it right here. And I just need to paste it right here. Next this messages property needs to become prompt. And conversation array needs to become conversation string.

[01:49] Okay let's log out the response and see what we get. And I'm just going to hit save and ask a random question in here. Let's open up the console and see what we get. And there we are we've got a response. And the response is a little bit strange. I'm just going to copy it into the editor so you can see it clearly.

[02:08] The response to my question how are you today was bizarrely this. It sounds like you've been on a real roller coaster. I'm sorry. Well that's okay we've still got quite a long way to go before we get this fine-tuned chatbot working. So it doesn't matter at all that it's giving us quite a random answer.

[02:27] The important thing is we're managing to make an API call to this new model. And we're getting a response. So in the next scrim let's get to work on these two lines of code right here.

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