AIC. - Artificial Intelligence Command

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIC. - Artificial Intelligence Command > AI - Set Parameters >

AIC. - Artificial Intelligence Command

AIC.Set Role

Previous Top Next


MiniRobotLanguage (MRL)

 

AIC.Set Role
Set the desired Role for the Ask-Chat Command.

 

clip0679

 

Intention

 

In the input and output JSON structure of the chat endpoint from OpenAI, the "role" field specifies the role of the message sender.
This plays a role with the "AIC.Ask Chat" Command, because it returns some of its Output in a variable called "Role".

Therefore you need to use the "AIC.Set Role" and the  "AIC.Get Role" to set and get this information.
 
The possible values for the "role" field are:

 

"system": This value indicates that the message is a system message. System messages are usually used to set the behavior of the assistant at the beginning of the conversation.
For example, a system message might instruct the assistant to speak like Shakespeare.

 

"user": This value indicates that the message is from the user. User messages are the prompts or questions that the user wants the assistant to respond to.

 

"assistant": This value indicates that the message is from the assistant. Assistant messages are the responses generated by the AI in reply to the user's prompts or questions.

 

The "role" field is important as it helps in distinguishing between different types of messages in the conversation and understanding the flow of the conversation.

 

You can set the Role of an "AIC.Ask Chat" Command using the "AIC.Set Role"-Command.

 

Important Note: The default/recommended role to set for AIC.Ask Chat is User. Using other roles may lead to undefined results.
   Using the Role "Assistant" for your prompt may lead to shorter answers (see Sample-Script below).
   No matter what role you specify, the AI will typically answer using the role "Assistant".

 

The "AIC.Set Role" command and the "AIC.Get Role" command operate on different registers; each command has its own dedicated register.

The "AIC.Set Role" command is utilized during a request to set a specific role. On the other hand, the "AIC.Get Role" command is used to retrieve the role that has been returned from the OpenAI server.

This distinction is crucial as the "AIC.Set Role" command is for specifying a role before sending a request, while the "AIC.Get Role" command is for obtaining the role information from the response received from OpenAI.

 

Options of Use:

 

a) You can specify a number 1,2 or 3. In this case the number will evaluate internally to these roles:

 

1 - System

2 - User

3 - Assistant  

 

b) You can type the first letter of each role. In this case the letter (lower or uppercase) will evaluate internally to these roles:

 

S - System

U - User

A - Assistant  

 

c) You can type the role (see below).  Most typing mistakes should be ignored and the right role should be assigned. You can also type other Roles not listed here, then these roles will be used.

 

 System, Assistant, User ..

   

 

Syntax:

 

AIC.Set Role|1

AIC.Set Role|u

AIC.Set Role|Assistant

 

 

Parameters:

<Role-Identifier>: "Assistant" or "User" or "System", alternative Options to specify the Role see above. All letters will be treated as lowercase. The default role is "user".

 

 

Syntax

 

 

AIC.Set Role[|P1]

AIC.sro[|P1]

 

 

Parameter Explanation

 
P1 - opt. "Assistant" or "User" or "System", alternative Options to specify the Role see above. All letters will be treated as lowercase. The default role is "user".

 

 

 

*Here is a Sample of the original returned JSON Data from the Chat-Endpoint.
 

  "id": "chatcmpl-7Zbc78I0ULOEdP1RfHTYPzRxsZSYZ",

  "object": "chat.completion",

  "created": 1688720424,

  "model": "gpt-3.5-turbo-0613",

  "choices": [

    {

      "index": 0,

      "message": {

        "role": "assistant",

        "content": "\"Imagine a world where technology has advanced to the point where humans can live forever. Explore the ethical implications and consequences of immortality on society, relationships"

      },

      "finish_reason": "length"

    }

  ],

  "usage": {

    "prompt_tokens": 20,

    "completion_tokens": 30,

    "total_tokens": 50

  }

}

 

 

 

Example

 

'*****************************************************

' EXAMPLE 1: AIC.-Commands

'*****************************************************

' Set OpenAI API-Key from the saved File

AIC.SetKey|File

 

' Set Model

AIC.SetModel_Chat|0

 

' Set Model-Temperature

AIC.Set_Temperature|0.5

 

' Set Max-Tokens (Possible lenght of answer, depending on the Model up to 2000 Tokens which is about ~6000 characters)

' The more Tokens you use the more you need to pay. But the longer Input and Output can be.

AIC.SetMax_Token|300

 

' Ask Question and receive answer to $$RET

$$QUE=Tell me what is X=3+5?

 

AIC.Set Role|User

AIC.Ask_Chat|$$QUE|$$REA

DBP.$$REA

 

AIC.Set Role|Assi

AIC.Ask_Chat|$$QUE|$$REC

DBP.$$REC

 

AIC.Set Role|System

AIC.Ask_Chat|$$QUE|$$RED

DBP.$$RED

 

:enx

 

 

Result:

 

[14:11:01] X = 3 + 5 is a mathematical equation. When you add 3 and 5 together, the value of X is 8.

[14:11:02] X = 8

[14:11:03] X = 3 + 5 is a mathematical equation. When you add 3 and 5 together, the value of X is 8.

 

 

 

Remarks

 

Important Note: The "AIC.Set Role" command and the "AIC.Get Role" command operate on different registers; each command has its own dedicated register.

The "AIC.Set Role" command is utilized during a request to set a specific role. On the other hand, the "AIC.Get Role" command is used to retrieve the role that has been returned from the OpenAI server.

This distinction is crucial as the "AIC.Set Role" command is for specifying a role before sending a request, while the "AIC.Get Role" command is for obtaining the role information from the response received from OpenAI.

 

Limitations:

-

 

 

See also:

 

  Set_Key

  Ask_Chat

  Ask_Completion