AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Tool and Function Management >

AIU. - Artificial Intelligence Utility

AIU.GetIsFunctionCall

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.GetIsFunctionCall
Check if the AI Response Involves a Function Call

 

Intention

 

GetIsFunctionCall Command: Identifying Function Calls in Responses
 
The GetIsFunctionCall command checks whether the most recent AI response involved a function call, returning a numeric value (1 for true, 0 for false).

This is crucial for workflows where the AI may invoke tools or functions, allowing you to adapt your script accordingly.

It’s part of the AIU - OpenAI API suite.

 

What is the GetIsFunctionCall Command?

 

This command retrieves a flag indicating if the last AI operation (e.g., chat or responses completion) triggered a function call, as configured by tools set via AIU.SetTools.

The result can be stored in a variable or placed on the Top of Stack (TOS) for further processing.

 

Why Do You Need It?

 

This command is useful for:

Conditional Logic: Adjust script behavior based on whether a function was called.

Debugging: Verify if tool integration is working as expected.

Workflow Optimization: Handle function call responses differently from standard text outputs.

 

How to Use the GetIsFunctionCall Command?

 

Call the command after an AI operation (e.g., AIU.Chat) to check if a function call occurred.

You can optionally specify a variable to store the result (1 or 0); otherwise, it’s placed on the TOS. Function calls depend on tools configured via AIU.SetTools and AIU.SetToolChoice.

Available models and their prices (as of March 18, 2025, from OpenAI’s pricing page) include:

gpt-4o: $5.00/1M input tokens, $15.00/1M output tokens (multimodal, 128K context).

gpt-4o-mini: $0.15/1M input tokens, $0.60/1M output tokens (cost-effective, 128K context).

gpt-4-turbo: $10.00/1M input tokens, $30.00/1M output tokens (high performance, 128K context).

gpt-3.5-turbo: $0.50/1M input tokens, $1.50/1M output tokens (dialog-optimized, 16K context).

o1-preview: $15.00/1M input tokens, $60.00/1M output tokens (advanced reasoning, 128K context).

o1-mini: $3.00/1M input tokens, $12.00/1M output tokens (reasoning, cost-effective, 128K context).

 

Example Usage

 

AIU.SetTools|{"function":"get_weather"}

AIU.Chat|What's the weather today?|$$RES

AIU.GetIsFunctionCall|$$FUN

DBP.Function Call Detected: $$FUN

 

This checks if the chat response invoked a function (e.g., get_weather), storing the result (1 or 0) in $$FUN.

 

Illustration

 

┌────────────────────────────┐

│ AI Response                │

├────────────────────────────┤

│ Function Call? (1 or 0)    │

└────────────────────────────┘

A simple check to determine if the AI invoked a function.

 

Syntax

 

AIU.GetIsFunctionCall[|P1]

AIU.Get_IsFunctionCall[|P1]

 

Parameter Explanation

 

P1 - (Optional) The variable to store the result (1 if a function call occurred, 0 if not). If omitted, the result is placed on the Top of Stack (TOS).

 

Example

 

AIU.SetTools|{"function":"calculate_sum"}

AIU.Chat|Add 5 and 7|$$RES

AIU.GetIsFunctionCall|$$CHK

IVF.$$CHK

 DBP.Function called: $$RES

EIF.

ENR.

 

Remarks

 

- Must be called after an AI operation (e.g., AIU.Chat) to reflect the latest response.

- Returns 0 if no tools are configured or no function was called.

 

Limitations

 

- Only reflects the most recent AI response; earlier responses are not tracked.

- Dependent on the AI model supporting function calls and proper tool configuration.

 

See also:

 

AIU.SetTools

AIU.SetToolChoice

AIU.Chat

Response Analysis Getters