HELP!

llmCall

This xpertrule object method makes a call to an LLM which has been registered in the deployment server. A deployment server can have several LLMs / models registered with each having a unique LLM KEY. This key is passed to the llmCall method as the first parameter along with the prompt and various options.

Parameters

result = xpertrule.llmCall(deploySvrLLMkeyname, promptOrBody, options);
parameter name Type Description
deploySvrLLMkeyname string The LLM API key as specified in the deployment server. LLM keys are maintained by the deployment server administrator via the LLM Keys burger menu option
promptOrBody string or object At it's simplest this parameter is just the prompt to send to the LLM. However if the messageAsPrompt option is set, this parameter is a JavaScript object which represents the body of the POST message to the LLM. n.b. The "model" property of the message is overwritten by the model specified by the Deployment server LLM key
options object An optional object containing various setting to allow additional control over the LLM call. See the next section for more details

The options Parameter Settings

setting name Type Description
messageAsPrompt boolean If false, the promptOrBody parameter of the llmCall is the actual prompt string. If true, then the promptOrBody parameter is a JavaScript object containing the POST body sent to the LLM. As noted, if the body is supplied, the model property is overwritten by that held by the deployment server
includeDoc string If specified, this is the URL of a file uploaded to and stored on the deployment server (e.g. via a file upload dialog control). This document is appended to the messages sent to the LLM
timeout integer The maximum number of seconds to wait for a response from the LLM (0 = no timeout)

Return Object

The result of a call to xpertrule.llmCall is a JavaScript Object. This object always contains an ok property. If ok == true then the result object will contain a reply property which holds the LLM response as a string, and an extra property which holds the full LLM response as a JavaScript object. If ok == false, an error property in the result contains details about the error.

Simple LLM call

let r = xpertrule.llmCall("dsLLMkey", "Who is the president of France?");
if (!r.ok) {
    xpertrule.message(r.error);
} else {
    xpertrule.message(r.reply);
}

Advanced LLM call

let r = xpertrule.llmCall(
    "dsLLMkey",
    {
        model: "gpt-4o-mini",
        messages: [
            {
                role: "system",
                content: "You are a smarty pants who knows everything"
    		},
    		{
                role: "user",
                content: "Who is the president of France?"
    		}
        ],
        temperature: 0.4,
        max_completion_tokens: 2048,
    },
    {
        messageAsPrompt: true,
        includeDoc: #pdfUploadedFile.val(),
        timeout: 60
    }
);
if (!r.ok) {
    xpertrule.message(r.error);
} else {
    xpertrule.message(r.reply);
}

For more information on the body of the POST message, see the openAI documentation

On This Page