AIG. - AI Google Gemini Integration

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > A.Tools-Configuration >

AIG. - AI Google Gemini Integration

AIG.MapToolHandler

Previous Top Next


MiniRobotLanguage (MRL)

 

AIG.MapToolHandler
Link an AI Tool to a Script Label

 

Intention

 

This command registers a connection between a specific AI Tool Name (e.g., "get_weather") and a specific Label in your robot script (e.g., ":Weather_Sub"). This "Map" is used by the AIG.DoToolCall command to automatically jump to the correct code block when the AI requests a function.

 

What is the MapToolHandler Command?

 

It builds an internal registry (Event Map). You call this command once for every tool you have defined in AIG.SetTools.

 

Visualizing the Event Map

 

 +---------------------------+

 � AI Tool Name � � � � � � �� Script Label

 +---------------------------+----------------------+

 � "set_light" � � � � � � � � --> :Light_Handler � �

 � "check_status" � � � � � �� --> :Status_Handler ��

 � "calc_sum" � � � � � � � �� --> :Math_Handler � ��

 +--------------------------------------------------+

 

How to Use

 

Provide the name of the tool (as defined in your JSON/Array) and the Label you want to execute.

 

Example Usage

 

' 1. Define Tools (Setup)

$$TOOL1=get_time|Get current time

$$TOOL2=say_hello|Say hello to user|name:str:User Name

ARR.clm|10

ARR.Set|10|0|$$TOOL1

ARR.Set|10|1|$$TOOL2

AIG.SetToolsFromArray|10

 

' 2. Map Tools to Labels (The Registration)

AIG.MapToolHandler|get_time|:Sub_GetTime

AIG.MapToolHandler|say_hello|:Sub_SayHello

 

' 3. Run AI

AIG.Ask|What time is it?

AIG.DoToolCall ' <- This will automatically jump to :Sub_GetTime

ENR.

 

' --- Handlers ---

:Sub_GetTime

 DBP.The time is: $$TIME

 RET.

 

:Sub_SayHello

 AIG.GetToolParam|name|$$NAM

 DBP.Hello $$NAM!

 RET.

 

Syntax

 

AIG.MapToolHandler|P1|P2

AIG.mth|P1|P2

 

Parameter Explanation

 

P1 - (String) The Tool Name exactly as defined in SetTools.

P2 - (String) The Script Label to call (must start with ":").

 

See also:

 

? AIG.DoToolCall (The dispatcher)

? AIG.SetToolsFromArray (Define the tools)