AI - Direct Access

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIC. - Artificial Intelligence Command > AI - Direct Access >

AI - Direct Access

AIC.Get Content

Previous Top Next


MiniRobotLanguage (MRL)

 

AIC.Get Text
Get the Text Result of the Ask-Completion, Ask_GPT4All and other Commands.

 

B01003

 

Intention

 

Some Commands will return their Output in a Variable(Array) called "Text", in that case you will get the Output using the "AIC.Get Text"-Command.

 

In case you have set "AIC.Set Number" to any number higher then "1", you will receive multiple Answers from the AI.

They may be equal (in Text-Generation, if Temperature is high) or not (in Image Generation mostly not).
 

You can specify which of these multiple Answers you want to have returned by specifying the Index of the Answer after the Command.

To keep things equal with the underlying JSON Structure, the Index-Number of the first Answer is zero (you can leave it empty or write "0").

 

In case you specify

 

AIC.Set Number|4

 

then you can use "AIC.gtx" Command to retrieve the Text with the Index 0 to 3. Because Index starts at "0".

 

You can use the  

AIC.Get Several|5|$$NUM

  Command to find out how many Answers have been delivered by the AI.

 

 

Syntax:

 

AIC.Get Text|<Index Number>|<Variable for Result>

 

Parameters:

<Number>: An integer value starting at zero, valid to the Value that has been specified using  "AIC.Set Number" Minus 1 (because we start with "0").

For example if you have specified to get just 1 Answer - which is the normal case - then the only valid number is "0".

If you are waiting for 2 Answers from the AI, the possible numbers are "0" and "1". This number representing the Array Index of the Output you want to get.

<Variable for Result>: This is a placeholder for the variable where you want to store the content retrieved by the "AIC.Get Content" command.
This variable will hold the data from the specified index in the output array. If omitted, TOS is used.

 

Example Usage:

 
AIC.Set Number|5
AIC.Get Text|4|$$RET

 

This example we have set the number of Results/Answers we want from the AI to 5. So we get 5 Answers,their Index-Numbers range from "0" to"4".

Here we retrieve the last answer which has Index 4.

 

 

 

Syntax

 

 

AIC.Get Text[|P1][|P2]

AIC.gtx[|P1][|P2]

 

 

Parameter Explanation

 
P1 - opt. Variable or numeric value, this is the number of the alternative results, you want to be returned.  

P2 - opt. Variable for result. If omitted TOS is used.  

 

 

*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_Completion|2

 

' 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

' We ask for 3 results.

 

AIC.Set Number|4

 

AIC.Ask_Completion|$$QUE|$$REA

' The Command will return all results in one Variable

DBP.$$REA

DBP.+++++++++++++++++++

DBP.Here we get the results separated:

FOR.$$LOP|0|3

  AIC.gtx|$$LOP|$$RET

  DBP.---------------------

  DBP.Result No.$$LOP

  DBP.$$RET

  DBP.---------------------

NEX.

:enx

ENR.

 

 

 

Result (removed some Linefeeds):

 

[Answer:000] X=3+5 is 8.

[Answer:001] X=3+5 is 8.

[Answer:002] X=3+5 is 8.

[Answer:003] X=3+5 is 8.

 

[14:32:15] +++++++++++++++++++

[14:32:15] Here we get the results separated:

[14:32:15] ---------------------

[14:32:15] Result No.0

[14:32:15] X=3+5 is 8.

[14:32:15] ---------------------

[14:32:15] ---------------------

[14:32:15] Result No.1

[14:32:15] X=3+5 is 8.

[14:32:15] ---------------------

[14:32:15] ---------------------

[14:32:15] Result No.2

[14:32:15] X=3+5 is 8.

[14:32:15] ---------------------

[14:32:15] ---------------------

[14:32:16] Result No.3

[14:32:16] X=3+5 is 8.

[14:32:16] ---------------------

 

 

 

Remarks

  -

 

Limitations:

-

 

 

See also:

 

  Set_Key

  Ask_Chat

  Ask_Completion