|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Session and Storage Management > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.SetUser
Set the User Identifier for the Session
Intention
SetUser Command: Define Session Identity
The SetUser command assigns a user identifier to the current AI session, enabling tracking or personalization of interactions.
This is useful for associating requests with a specific user in logs or analytics.
It’s part of the AIU - OpenAI API suite.
The SetUser command sets a string identifier for the user, which is included in API requests for operations like AIU.Chat or AIU.Responses.
This identifier (e.g., "user123") is sent as metadata with requests, aiding in tracking or debugging without directly affecting response content or token costs.
Setting a user identifier is valuable for:
•Tracking: Monitor which user initiated specific requests in multi-user environments.
•Debugging: Correlate API logs with user activity for troubleshooting.
•Personalization: Potentially customize responses based on user ID (model-dependent).
Provide a single string parameter representing the user identifier (e.g., a name, ID, or code).
This setting persists for the session and is sent with API calls, with negligible impact on token usage. 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-3.5-turbo: $0.50/1M input tokens, $1.50/1M output tokens (dialog-optimized, 16K context).
Example Usage
AIU.SetUser|user123
AIU.Chat|Hello, who am I?|$$RES
DBP.Response: $$RES
Sets the user ID to "user123" for the session; the API logs this with the chat request.
Illustration
┌──────────────┬────────────────────┐
│ User ID │ API Metadata │
├──────────────┼────────────────────┤
│ user123 │ "user": "user123" │
├──────────────┼────────────────────┤
│ alice │ "user": "alice" │
└──────────────┴────────────────────┘
Illustration of user IDs sent as metadata in API requests.
Syntax
AIU.SetUser|P1
AIU.Set_User|P1
Parameter Explanation
P1 - A string specifying the user identifier (e.g., "user123", "alice"). Required.
Example
AIU.SetUser|bob
AIU.Chat|What’s the weather?|$$WEA
DBP.Weather Info: $$WEA
ENR.
Remarks
- The user ID is optional in the OpenAI API but useful for tracking; it persists until changed or the session ends.
- No default value is set during initialization; it’s empty until specified.
Limitations
- Requires exactly one parameter; omitting or adding extra parameters triggers an error (%IC_ER_PA).
- The identifier’s length or format isn’t validated; excessively long IDs may be truncated by the API.
See also:
• AIU.Chat