Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. Tutorials
  4. ChatGPT AI - Ask Me Anything! (Difficulty: 1)

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

Scheduled Pinned Locked Moved Tutorials
1 Posts 1 Posters 6.4k Views
  • 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.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

    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
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode