|
<< Click to Display Table of Contents >> Navigation: »No topics above this level« AIG. - AI Google Gemini Integration |
MiniRobotLanguage (MRL)
AIG. Endpoint Management
Understanding Dynamic Endpoint Construction
Concept
The AIG framework uses a dynamic approach to determine the API endpoint URL used for Google Gemini requests. Instead of storing a fixed URL, the framework constructs the correct endpoint each time it's needed (primarily when making an API call like AIG.ask or AIG.askvision).
This ensures that the endpoint always matches the currently selected model and the desired API operation (action).
Construction Components
The final endpoint URL is assembled by the internal AIG.Get Endpoint function using three parts:
1.Base URL: A fixed constant $AIG_BaseEndpoint (e.g., `https://generativelanguage.googleapis.com/v1/models`).
2.Model Name: The currently selected model name, retrieved from the AIG_Model global variable (set via AIG.setmodel). The surrounding quotes are automatically removed during construction.
3.Action Suffix: A string defining the API operation, retrieved from the AIG_EndpointAction global variable (set via AIG.setendpointaction or its alias AIG.setendpoint). The default is usually `":generateContent"`.
Format: [Base URL] / [Model Name] [Action Suffix]
Controlling the Endpoint
•Changing the Model: Use AIG.setmodel. This updates the middle part of the dynamically constructed URL.
•Changing the Action: Use AIG.setendpointaction (or the alias AIG.setendpoint) to change the suffix (e.g., to `":embedContent"`). Passing an empty string resets it to the default action (`":generateContent"`).
Note: There is no longer a command to set the entire URL directly. The endpoint is always constructed from its components.
Retrieving Endpoint Information
•AIG.getendpoint: Returns the full URL that will be used, constructed from the current model and action suffix.
•AIG.getendpointaction: Returns only the currently configured action suffix string (e.g., `":generateContent"`).
•AIG.getmodel: Returns the currently selected model name (including quotes).
Example
// Initial state (assuming default model is gemini-pro)
AIG.getendpoint|$$url
DBP.URL: @$$url // Output: .../gemini-pro:generateContent
// Change model
AIG.setmodel|"gemini-1.5-flash"
AIG.getendpoint|$$url
DBP.URL: @$$url // Output: .../gemini-1.5-flash:generateContent
// Change action suffix
AIG.setendpointaction|:embedContent
AIG.getendpoint|$$url
DBP.URL: @$$url // Output: .../gemini-1.5-flash:embedContent
// Reset action suffix
AIG.setendpointaction|""
AIG.getendpoint|$$url
DBP.URL: @$$url // Output: .../gemini-1.5-flash:generateContent
See also:
• AIG.setendpointaction (or AIG.setendpoint)