LoadAISession()
Restores an AI session from a serialized JSON string or struct. This function recreates an AI session with:
- Original configuration settings (temperature, limits, timeouts)
- Complete conversation history
- System message prompt
The function supports loading sessions by:
- AI engine name
- Engine ID (using
id:prefix) - Default engine (using
default:prefix)
This function pairs with SerializeAISession() to provide persistence for AI conversations across requests or application restarts.
Introduced: 7.0.0.195
LoadAISession( name=string, data=any );
Returns: any
| Argument | Description |
|---|---|
|
name
string,
required
|
edit
Specifies which AI endpoint configuration to use. Can be provided in two formats:
The name of an endpoint as defined in the Lucee Administrator (similar to how datasource names work)
Using the format "default:category" to use the endpoint configured as the default for that specific category in the Lucee Administrator. Currently supported default categories:
The endpoint configurations and their default category assignments are managed in the Lucee Administrator. Alias: aiName, nameAI |
|
data
any,
required
|
edit
The serialized AI session data, which can be provided as either:
Must contain the following keys:
Incomplete or improperly formatted data may cause initialization errors. |
Examples
edit//AI service name eg:test_ai
Ai_session = CreateAISession(name:'test_ai', systemMessage:"Answer as Slim Shady.");
result = SerializeAISession(Ai_session);
writeDump(LoadAISession('test_ai', result));
See also
- AI / LLM Integration
- SerializeAISession()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)