ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

Thumbnail

Openai Chatbot

by OpenAI

Chatbot based on OpenAI GPT-3 gives your robot a human-like personality for conversation.

How to add the Openai Chatbot robot skill

  1. Load the most recent release of ARC (Get ARC).
  2. Press the Project tab from the top menu bar in ARC.
  3. Press Add Robot Skill from the button ribbon bar in ARC.
  4. Choose the Artificial Intelligence category tab.
  5. Press the Openai Chatbot icon to add the robot skill to your project.

Don't have a robot yet?

Follow the Getting Started Guide to build a robot and use the Openai Chatbot robot skill.

How to use the Openai Chatbot robot skill

Give your robot a personality and conversational ability. This robot skill adds chatbot capability to your robot so you can have meaningful conversations that it will remember. Configure the personality in any way you wish so the robot can prefer specific subjects or have particular opinions.

OpenAI’s mission is to ensure that artificial intelligence benefits all of humanity. This effort is essential to training AI systems to do what humans want. Generative Pre-trained Transformer 3, commonly known by its abbreviated form GPT-3 robot skill, is an unsupervised Transformer language model. This GPT-3 robot skill can be used with your robot for human-like conversation.

Screenshot
User-inserted image



Configuration


The configuration menu has several options. You can add keywords with associated scripts that execute with responses from the Bot. You can also have a script that runs every response received. By default, the All Responses script will speak the response out of the PC speaker.
User-inserted image


Default Script
User-inserted image

By default, the All Responses script from the script tab will speak the response out of the PC speaker. If you use an EZB that supports audio output, the command can be edited to Audio.sayEZB() to speak out of the EZB. 

Variables
Variables are used to store the user's request and the bot response. This allows the robot to speak the response defaulted in the All Response scripts.
User-inserted image


Settings
The settings tab has options for configuring the bot behavior and the API key. Obtain an API Key from the OpenAI website and paste it into the appropriate box. When choosing a model, view the pricing and details on their website here: https://openai.com/api/pricing/
User-inserted image



Best Match
This list of words/phrases will be used to guess the best match based on the conversation. This allows your robot to execute a script matching the conversation's subject or tone. The robot can be sad or happy based on the type of conversation. Or have the robot dance when discussing a party or favorite music. A few examples provide suggestions for scripts to associate with them.

There is an option to determine what input the match should be based on. By default, the match will use the AI response to provide the most accurate interactive responses. If unchecked, the match will be based on the user's input.
User-inserted image



Edit Memory


The Open AI system does not use a session to maintain conversation history. To overcome this, the entire conversation history is held in the robot skill and sent to the Open AI system for every request. Occasionally, the conversation may become too complicated for the Open AI to understand. If you receive many "I have nothing to say to that" responses, the conversation memory may need to be "Cleaned up" or "Cleared." The Memory button allows for resetting or editing the conversation memory. Optionally, there is a ControlCommand() to reset the memory programmatically and set a default Bot Description value to give the chatbot a custom name.

User-inserted image




Control Commands


Several ControlCommand() for this robot skill enables interaction with other robot skills. 

Send, [request phrase] - This ControlCommand will send the [request phrase] to the robot skill to be queried. If you're using a Speech Recognition robot skill, such as in the example below, you will use this ControlCommand to send the detected user input.

ResetMemory - This will reset the conversation and memory to the default state. 

ResetMemory, [Bot Desription] - This will reset the conversation and memory to the default state and set the bot description to a custom value. Use the Memory -> Edit menu option to view the default bot description and see how it can be edited. For example, this is the default bot description "The following is a conversation with an AI robot. The robot is named Synthiam. The robot is friendly, creative, and clever.".  This bot description can be tailored to your needs, such as "The following is a conversation with an AI robot. The robot is named Synthiam. The robot enjoys discussing science. The robot's favorite sport is hockey."

API Key


An account is required on the OpenAI website to use the service. Once an account is created, you will have an API key to use in the robot skill.

1) Visit the OpenAI website and select the API option from the menu. 
User-inserted image


2) Press the SIGNUP option to create an account
User-inserted image


3) Once the account is created, press your Username icon to view the drop-down. And select the View API Keys option.
User-inserted image


4) Copy your API key
User-inserted image



5) Paste the API key in the robot skill configuration menu
User-inserted image



Open AI's GPT-3 Overview


Generative Pre-trained Transformer 3, commonly known by its abbreviated form GPT-3, is an unsupervised Transformer language model and the successor to GPT-2. It was first described in May 2020. OpenAI stated that the full version of GPT-3 contains 175 billion parameters, two orders of magnitude larger than the 1.5 billion parameters in the full version of GPT-2 (although GPT-3 models with as few as 125 million parameters were also trained).

OpenAI stated that GPT-3 succeeds at specific "meta-learning" tasks. It can generalize the purpose of a single input-output pair. The paper gives an example of translation and cross-linguistic transfer learning between English and Romanian and between English and German.

GPT-3 dramatically improved benchmark results over GPT-2. OpenAI cautioned that such scaling up of language models could be approaching or encountering the fundamental capability limitations of predictive language models. Pre-training GPT-3 required several thousand petaflop/s-days of computing, compared to tens of petaflop/s-days for the full GPT-2 model.

Like its predecessor, GPT-3's fully trained model was not immediately released to the public on the grounds of possible abuse until now for select partner companies.




Demo Example


Here is an example of using the OpenAI chatbot to have verbal conversations. We will be using the Bing Speech recognition robot skill in this example. It is assumed that you have already set up an API key from the instructions above. Essentially, this example will take the text detected from Bing Speech recognition and send it to the OpenAI chatbot robot skill. The OpenAI chatbot robot skill will then speak the chatbot's response.

1) Add the OpenAI chatbot to your ARC project. Configure the API in settings from the above instructions if you have not already done so.
User-inserted image


2) Add the Bing Speech Recognition robot skill to your ARC project. 
Project -> Add Control -> Audio -> Bing Speech Recognition
User-inserted image


3) Your project will now have both the OpenAI and Bing Speech recognition robot skills
User-inserted image


4) Press the Configure button on the Bing Speech recognition robot skill
User-inserted image


5) Press the button to edit the script for All Recognized Script
User-inserted image


6) We will use JavaScript in this example. When the script editor loads, select the JavaScript tab.
User-inserted image


7) Right-click in the editor and navigate the menu to the OpenAI selection. Choose the SEND option
User-inserted image


8) A command will be added to the code editor. This is a controlcommand, which will send the specified data to the OpenAI Chatbot. We will edit this command to send the variable containing the Bing Speech Recognition text detected.
User-inserted image


9) Highlight the "[requested phrase]" text
User-inserted image


10) Delete the "[requested phrase]" text
User-inserted image



11) Select the Global Variables tab 
User-inserted image


12) Place your cursor where the text you have just erased once was.
User-inserted image


13) Now click on the $BingSpeech variable from the Global Variables. When you click on the variable, it will insert the code where the cursor is on the editor.
User-inserted image


14) Your line of code should now look like this. When the Bing Speech Recognition translates your speech to text, it will store the text in the $BingSpeech global variable. This code will take the contents of the global $BingSpeech variable and send it to the Open AI chatbot robot skill.

Code:


ControlCommand("OpenAI Chatbot", "Send", getVar("$BingSpeech") );
User-inserted image



15) Save the code editor
User-inserted image


16) Save the configuration
User-inserted image


17) Now press the Start Recording button and speak to the robot. Press the Stop Recording button when you have completed speaking.
User-inserted image


18) You are now having a conversation with your robot!:)

Next Steps


You can add this to any robot and start modifying features to make the robot do specific actions or behaviors based on phrases. Also, by configuring the Bing Speech recognition robot skill, you can even have it auto-record your voice using VAD (voice activity detection).

If your robot has an EZB supporting audio, such as an EZ-Robot v4, you can change the Open AI script to sayEZB() and have the voice come from the robot speaker. There are many things you can do, be creative and have fun!

ARC Pro

Upgrade to ARC Pro

ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!

PRO
Synthiam
#34  
I know it’s being looked at. It’s the weekend now so they’ll be back at it early next week. If it’s something on our end, we usually get it done right away. I’m guessing it’s something with the api or 3rd party dependency. I’ll give you an update Monday morning when I hear more:)
PRO
Colombia
#35  
HI DJ, I am also experimenting same issue. Any update on this?  Thanks in advance.
PRO
Synthiam
#36  
The latest update fixes the past issue: "I have nothing to say to that." Enjoy!
PRO
Australia
#38  
Yes, the update did fix the 'I have nothing to say about that' error. Fantastic, I will now upgrade to PRO for my InMoov project!
PRO
Synthiam
#39  
I’m really enjoying the recent change to this skill. It’s super responsive and holds an amazing conversation. I think there’s a way to get the subject generalization as a keyword. If so, we could extract that to allow you to have scripts execute on the subject rather than keywords. I’ll have a peek myself first to see if it’s possible
PRO
Synthiam
#40   — Edited
Oh wow, this is so cool! So I've added a new feature to the robot skill that determines the tone/mood of the conversation. Each time there is user input, the Open AI engine will determine if it matches one of the tones/moods you have provided. Associated scripts can be executed based on the subject's tone/mood. 

For example, you can have the robot do pushups when discussing health or weight. You can have the robot execute an Auto Position to dance when talking about music or a party. Or have the robot appear sad when a conversation has turned negative. A few examples are provided by default that you can add your code.

User-inserted image


Here's an example of matches being detected. Scripts can run for each match, making the conversation more animated and interactive.
User-inserted image
PRO
Colombia
#41  
This is really cool! Thanks
#42  
Hi,

Thanks for the update! I finally had a chance to try it again. Unfortunately OpenAI expired my free credits a few months ago and it requires a different telephone number for a different account. sigh. Anyway, I finally put my credit card in and paid for some tokens and it is working again--kind of. I have two issues: 

1. Every so often I am again getting "I have no response for that." It seem to happen most often with short queries. 

2. The chatbot says her name is Synthiam. That is a nice name, but not the name of my robot. Can I change that? 

3. It would be really great if it would truncate any text after the last punctuation mark. Having the robot say a part of a sentence just sounds weird. I suppose I could intercept the text returned and write code to do it myself, BUT...

Code:

OpenAI initialized
Human: what is your name
AI: My name is Synthiam.
Human: how are you
AI: I am doing great.
Human: what's new with you?
AI: I am always creating new things.
Human: Tell me more.
AI: I have no response for that

and

Code:

OpenAI initialized
Human: good morning
AI: I have no response for that
Human: good night
AI: I have no response for that
Human: good night dear
AI: I have no response for that
Human: good night dear robot
AI: Thank you for spending your time with me. I hope
--Thomas (Creator of Simone the A.I. Fembot)
PRO
Synthiam
#43   — Edited
The manual above explains the settings for expanding the response. I use 255 characters. 

The memory can be edited to change the name. More information in the manual on that as well.

Also, if you have changed settings and need to reset to defaults, remove the robot skill and add it again fresh. Your past conversation memory might be affecting future responses.
PRO
Synthiam
#44  
Updated to match on the AI response rather than the user's input by default. There is now a checkbox so that can be changed.

User-inserted image
#45  
Ah, Thanks DJ!!! I didn't realize that "Memory" was a dropdown menu. It looks like a label. Of course I could have clicked on it to try it. I know there are others like it. Lesson learned.  

Is it possible to edit the "memory" programmatically? It would be very good to be updated or purged in real time. 


Thomas

PS. This is getting expensive: $10 USD a day!!! At that rate I am probably not going to use it much with Simone. That's just too much!
PRO
Synthiam
#46  
You’ve spent $10 a day?! That’s a lot of queries I think. We used it for quite a bit the other day and it was little over $2
#47   — Edited
Yup. I finally figured out why. I found that when you send all of the memory text along with each query, it counts all of that as tokens. As the conversation continues, all of the prior conversation text is sent, pushing up the token usage!!!:( I see that with one lengthy conversation I was using over 2000 "prompt tokens" and 95 "completion tokens" per minute.:( That adds up fast!

Code:

5:32 AM
Local time: Aug 23, 2022, 10:32 PM
text-davinci, 6 requests
2,166 prompt + 95 completion = 2,261 tokens

I read that they are going to reduce their prices to about a half to a third of what they are now. I am looking forward to that!:D I'm having a lot of fun with it. It certainly makes my robot seem alive. It's a chatbot without all of the effort of updating ALICE.xD:DxD

--Thomas (Creator of Simone the A.I. Fembot)

PS. I see that we are using the Davinci model.
PRO
Synthiam
#48   — Edited
This skill has been updated (v10) to allow the programmatic setting of the memory and bot description. See the manual above for more information.
#50  
Thanks DJ!

Thanks for giving us the ability to set the memory programmatically. Thanks for letting us choose the model. And also, it is working SO VERY MUCH BETTER NOW!:D:D:D 

One last teeny tiny small request: Can you please give us the option of leaving out the rest of the default text when we set the memory? 

This is the text that I want to leave out: 

Code:

Human: Hello, how are you?
AI: I am doing great.
Thanks!

Thomas (Creator of Simone the A.I. Fembot)
#51   — Edited
Hello,

I spent another hour or so testing out the various models tonight. I used the same settings and a (long) list questions for each model. My questions were social, "What do you do for a living?" "Are you married?" "What are your favorite foods?" "Are you sentient?" etc. The replies were quite amusing. Generally speaking Ada and Babbage are not worth bothering with. They get too much wrong. Ada's replies sound down right stupid. Babbage is not much better. Now, Davinci at times sounded like a real person. Curie was a close second. I am going to see if Curie will be good enough for my robots since Davinci is too expensive. Yeah, I ran out of free tokens a long time ago. Sigh. After testing all 4, I now see why they are priced the way they are. 

After a few more dollars spent, I have these first impressions: 

Code:

   Ada:       $0.0008 / 1K tokens - Ada is not too smart as a person. It gets a lot of questions wrong.
Babbage:  $0.0012 / 1K tokens - Babbage is much smarter. It gets some things wrong like names.
Curie:  $0.0060 / 1K tokens - Almost the same as Davinci but 1/10th the price.
Davinci: $0.0600 / 1K tokens - too expensive and not sure if it is worth it. Quite impressed though.
#53  
"...research and development between $11.5 million and $27.6 million..." and "...the hardware costs of running GPT-3 would be between $100,000 and $150,000 without factoring in other costs (electricity, cooling, backup, etc.)."

Not cheap. I hope they don't run out of money and close up shop.