I think Martin’s asking how he might define/configure that Ai feature within an Application.cfm rather than Application.cfc. Note he refers to cfapplication (though he shows using the script equivalent of that. And of course one can use cfapplication outside of just Application.cfm, but that’s the most common place).
Have I got that right, Martin?
And if I can expand the topic a bit, this would not be the only app-level setting that one may find that there is provision to control it as a property of Application.cfc BUT NOT as attribute of cfapplication (at least in CF I’m sure, and seemingly for Lucee from what he’s said.)
And I know there’s no resource from Adobe or at cfdocs.org that outlines what those inconsistencies are for ACF. I don’t expect there’s one for Lucee, either.
And yes, one could dig into the Lucee code to find these differences (though not the admin code itself). For CF (and for Lucee) one could at least use the docs to see how they differ in what can be done in cfapplication vs properties of Application.cfc. But my suspicion is that the docs would not be complete on this matter (for either engine).
I realize it’s not a topic that’s frequently requested, but this discussion reminds me that it is an issue sometimes (even if this ai attribute may be added to Lucee’s cfapplication tag/script stmt).
To give more context, I am working on a component that could be dropped into any application and I want this to be self-sufficient. The component has an AI element to it to analyse some data, and I was hoping to either pass in the name of an AI already defined in the admin, .CFConfig.json or application.cfc OR pass in all or part of an AI definition - say ai type, model and apiKey - from which the component can define its own AI configuration.
I have used cfapplication in the past to allow mappings and datasources to be defined dynamically by components or frameworks by doing something like this:
/**
* @hint adds a mapping to our application
*/
public void function addCFMapping(required string name, required string path){
local.appMD = getApplicationMetadata();
local.appMD.mappings[arguments.name] = arguments.path;
application action="update" mappings="#local.appMD.mappings#";
}
// ==================
// I tried to do the same for AI
/**
* @hint adds an ai configuration to our application
*/
public void function addAIConfig(required string name, required struct config){
local.appMD = getApplicationMetadata();
local.appMD.ai[arguments.name] = arguments.config;
application action="update" ai=local.appMD.ai;
}
I was trying to do the same for ‘ai’ when I realised that it was missing from the cfapplication definition.
@Zackster The ability to pass the ai config into the CreateAISession function would be great! It would mean we do not have to mess with application settings at all.