AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Core Operations >

AIU. - Artificial Intelligence Utility

AIU.Chat

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.Chat
Perform a Chat Completion

 

Intention

 

Chat Command: Generating Conversational Responses
 
The Chat command enables you to interact with OpenAI’s chat models by sending a prompt and receiving a text-based response.

It’s ideal for automating conversations, answering questions, or generating content within your scripts.

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

 

What is the Chat Command?

 

The Chat command sends a user-defined prompt to an OpenAI chat model (e.g., gpt-4o, gpt-3.5-turbo) via the AIU.SetChatEndpoint and returns a text completion.

You can specify a variable to store the response and optionally copy it to the clipboard for further use.

 

Why Do You Need It?

 

Using the Chat command is valuable for:

Automation: Generate responses for user queries or scripted dialogues.

Content Creation: Produce text content like emails, reports, or creative writing.

Integration: Leverage AI responses in workflows with clipboard or variable output.

 

How to Use the Chat Command?

 

Provide a prompt string, an optional return variable, and an optional clipboard flag (0 or 1). The response is generated based on the current model and settings (e.g., temperature, max tokens).

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).

 

Example Usage

 

AIU.SetModel|gpt-4o

AIU.Chat|Tell me a joke|$$RES|1

DBP.Joke: $$RES

 

This sends a prompt, stores the response in $$RES, and copies it to the clipboard.

 

Illustration

 

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

│ Prompt                              │

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

│ Tell me a joke                      │

├──────┬──────────────────────────────┤

│ Resp │ Why don’t skeletons fight?   │

│      │ They don’t have the guts!    │

└──────┴──────────────────────────────┘

A simple chat completion example.

 

Syntax

 

AIU.Chat|P1[|P2[|P3]]

AIU.Chat|$$PRO[|$$RET[|CLIP]]

 

Parameter Explanation

 

P1 ($$PRO) - The prompt string to send to the chat model (required).

P2 ($$RET) - (Optional) The variable to store the response. If omitted, the response is not stored in a variable.

P3 (CLIP) - (Optional) A flag (0 or 1) to copy the response to the clipboard (1 = yes, 0 = no, default is 0).

 

Example

 

AIU.SetModel|gpt-3.5-turbo

AIU.Chat|What is the capital of France?|$$ANS|0

DBP.Answer: $$ANS

ENR.

 

Remarks

 

- Requires a valid API key set via AIU.Set_Key.

- Response is influenced by settings like AIU.SetTemperature and AIU.SetMaxToken.

 

Limitations

 

- Maximum prompt and response length depends on the model’s context window (e.g., 16K for gpt-3.5-turbo, 128K for gpt-4o).

- Requires an active internet connection and valid API credentials.

 

See also:

 

AIU.Chat_Vision

AIU.Set_Model

AIU.Set_ChatEndpoint

Operations