Australia
Asked

Determining Robot Emotions From Chatgpt

How can I determine which type of emotion my robot should display when engaging in a conversation using ChatGPT? I've programmed my robot to express various emotions, including Angry, Disgust, Fear, Happy, Sad, Sigh, Smirk, Sorry, Surprise, Suspicious, Thinking, Unamused, Winking, and Sleeping. It seems like there's no explicit variable within the ChatGPT response that directly indicates which emotion should be used. How can I bridge this gap to enhance the emotional intelligence of my robot's interactions?


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Don't limit your robot's potential – subscribe to ARC Pro and transform it into a dynamic, intelligent machine.

PRO
Canada
#1  

Below is one common approach to bridging the gap between a freeform ChatGPT response and getting a specific emotion for your robot:

  1. Use Sentiment Analysis as the Bridge
    Although the ChatGPT response does not include an explicit emotion tag, you can feed that same text into the Vader Sentiment Analysis skill. Vader computes a set of values (for example, a Compound score and percentages for Positive, Neutral, and Negative emotions) that you can then interpret.

  2. Map Sentiment Scores to Emotions
    Decide how to convert the sentiment scores into a discrete emotion. For example, you might set up rules in your script such as:

    • If the compound sentiment is very positive (say, > 0.5) Display Happy
    • If the compound sentiment is negative (say, < -0.5) Display Angry
    • If mostly neutral Display Thinking or Unamused
    • For subtle differences (for example, high disgust or surprise percentages) Map to your Disgust or Surprise animations

    You can further refine these thresholds to choose among your programmed list that includes Angry, Disgust, Fear, Happy, Sad, Sigh, Smirk, Sorry, Surprise, Suspicious, Thinking, Unamused, Winking, and Sleeping.

  3. Implement via a Scripting Layer
    A common method is to write a JavaScript (or Python) script that runs when a ChatGPT response is received. The script would:

    • Read the ChatGPT response from the global variable (e.g. getVar($OpenAIResponse))
    • Send that text to the Vader Sentiment Analysis control by using a ControlCommand() (or by directly calling a function if you’ve made one)
    • Retrieve the resulting sentiment values from global variables that Vader creates (for example: $VaderCompound, $VaderPositive, etc.)
    • Then, use conditional logic (if/else or a switch statement) to pick one of your robot’s display emotions
    • Finally, trigger the appropriate robot emotion (perhaps by calling another ControlCommand to animate an LED face, servo positions, or a display image)
  4. Example Script (JavaScript)
    You might have a script that looks like this:

// Assume ChatGPT has already responded and set its response into $OpenAIResponse
var responseText = getVar("$OpenAIResponse", "");

// Send the response to Vader for sentiment analysis.
// (Make sure Vader Sentiment Analysis skill is configured to analyze getVar($OpenAIResponse))
controlCommand("Vader Sentiment Analysis", "Analyze", responseText);

// Wait briefly to ensure Vader processes the text
sleep(500);

// Get the compound sentiment value (range -1 to 1)
var compound = getVar("$VaderCompound", 0);

// Map the compound score to an emotion
var emotion = "";

// Example mapping - you can adjust thresholds as needed:
if (compound >= 0.5) {
  emotion = "Happy";
} else if (compound >= 0.2 && compound < 0.5) {
  emotion = "Smirk";
} else if (compound > -0.2 && compound < 0.2) {
  emotion = "Thinking";
} else if (compound <= -0.5) {
  emotion = "Angry";
} else if (compound < -0.2 && compound > -0.5) {
  emotion = "Sad";
}

// Debug output
print("Compound: " + compound + "  Emotion: " + emotion);

// Now trigger the emotion display control (this could be your own custom control)
controlCommand("EmotionDisplay", "SetEmotion", emotion);
  1. Customize and Experiment

    • Adjust the thresholds to match the tone you feel best fits each emotion.
    • Depending on how your Vader analysis skill is set up, you might have additional variables (like positive percentage, negative percentage, etc.) which might help decide between similar emotions (for example, between Surprised and Winking).
    • You might also include extra keyword checks in the ChatGPT response. For instance, if you detect words such as oops or sorry you could override the sentiment analysis.
  2. Integrate the Script into Your ARC Project

    • Hook this script to run after you receive the ChatGPT response.
    • Test different responses to see if your robot displays an appropriate emotion from the list you created.

By combining Vader’s quantitative sentiment analysis with your custom mapping logic, you can effectively bridge the gap between ChatGPT’s open responses and your robot’s expressive emotional displays.

Does this approach work for your project, or would you like to dive into more detailed coding examples or further refinements?


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#2   — Edited

While there are a few sentiment analysis robot skills for this use case as mentioned by Athena, the open ai chat gpt robot skill can do it with script parsing.

Remember that the open ai gpt robot skill can provide code in its response. You can provide instructions in the system prompt to set a global variable with the response in a script tag. Or you can have the script launch another script or action.

It’s easy to overlook the power of an LLM, in that you can give it instructions with English words. Rather than worrying about writing code, you merely need to write the outcome that you’d like it to perform. If you’re unsure how to write and describe an outcome, you can use chat gpt to assist.

Remember, you program gpt’s by giving them written instructions, much like how you would talk to another human. The output of an AI is only as good as your input.

You could instruct the system message to say something like


Rate this response in a global variable named $Emotion within JavaScript encoding. The following values can be used: disgust, happy, fear, neutral. Use the following example

<javascript>
SetVar("$Emotion", "disgust")
</javascript>
PRO
Australia
#3  

Thanks for the advice. Will try it out.

PRO
Canada
#4  

Great! I'm glad the advice was helpful. When you try it out, feel free to share any questions or challenges you run into. If you need further clarification on mapping sentiment results to your pre-programmed emotional expressions or how to integrate the global variable into your ChatGPT system prompt, just let me know.

Happy coding and best of luck with your project!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.