Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    ChatGPT AI - Ask Me Anything! (Difficulty: 1)

    Tutorials
    1
    1
    417
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • info-creaticode
      CreatiCode last edited by admin

      Introduction

       

      This is a very simple tutorial that shows how to use the ChatGPT block to create a virtual character that can answer user questions.

      simplechat.gif

       
       

      Step 1 - A New Project

       

      Sign in to the CreatiCode playground, and create a new project. You can name the project “Ask me anything”.

       
       

      Step 2 - Add Sprite and Backdrop

       

      You can pick any sprite and backdrop for this project. For example, a professor sprite and a library backdrop. Drag the sprite to the left to leave more space for the speech bubble:

      8a5c6dcc-daf5-4216-a75c-418018d05938-image.png

       
       

      Step 3 - Ask and Wait

       

      When the green flag is clicked, the sprite should ask the user to input a question. We can use the “ask and wait” block like this:

      b73188c5-9ccd-4d09-a240-82b14a1aa9a9-image.png

       
      It should look like this when you click the green flag button:

      7a4b2b24-ec03-46b3-96ed-cbdec059fb8a-image.png

       
       

      Step 4 - Get ChatGPT’s answer to this question

       

      After the user inputs a question and presses the ENTER key, the user’s input will be stored in the “answer” block. Note that it is called “answer”, but in this case, its content is actually the question from the user.

      We will then send this question to ChatGPT and wait for its response:

      09d2d035-3e6e-4d4d-bf07-3d8fe32d553e-image.png

       
      Explanation of the parameters:

      • Request: the “answer” block is sent to ChatGPT as the request.
      • Result: the response from ChatGPT will be stored in the “result” variable.
      • Mode: the “waiting” mode means we will not run any block below this block until the full response from ChatGPT has been received and stored in the result variable.
      • Length: We are setting a maximum length of 500, which means if ChatGPT’s response is too long, it will be cut off. Note that this is 500 tokens, so approximately 375 English words, since tokens can be a part of a word.
      • Temperature: We are using a high temperature of 1, which makes ChatGPT more creative.
      • Session: We are starting a new chat session, so there is no conversation history.

       
       

      Step 5 - Say the Response

       

      After the response from ChatGPT is stored in the result variable, we simply need to make the sprite say it with a speech bubble like this:

      4d185ecb-6a2c-4c47-8399-55e0e3f3a649-image.png

       
      This is the final result:

      simplechat.gif

       
       

      Additional Challenges

       

      Here are some additional challenges for you to try:

      • Shorter Answers: Try to make the sprite give very short and concise answers each time. For a hint, changing the token limit won’t help, and you need to modify the request that is sent to ChatGPT.

      • Continue the Conversation: Currently, ChatGPT does not “remember” previous questions and answers. You can change it by adding a new stack of code: whenever the sprite is clicked, ask the user to input a question, but when you send it to ChatGPT, use the “continue” session type.

      • Different Tones: Currently, ChatGPT generates its response as “a helpful assistant”. You can change its tone to match the sprite you have chosen, such as a professor.

      1 Reply Last reply Reply Quote 0
      • Pinned by  info-creaticode info-creaticode 
      • First post
        Last post