Note
This feature requires special configuration. Contact our Platform Support Team or your CSM to help enable it.
Jobs using custom JavaScript have access to a global value CF.API_TOKEN. The value is an encrypted string that contains job id, worker id, and project id (if present).
That token can be used in requests to API endpoints that support that kind of authorization. For example contributor API endpoint for invoking LLM models.
Appen's LLM Data Product Templates include templates with JavaScript pre-coded to call models. For example, the following job allows you to upload a prompt and provides a button for the contributor to press that will generate responses from two models (or versions).
Models first need to be associated to the Team where the job will be run from and enabled in the individual job (as in this article). Then, find the lines in the JS relating to Model Parameters and update with the appropriate Model ID(s).
//Enter Model Parameters here:var model_id_1 = 17var model_input_1 = [{ "message": "", role: "user" }]var model_id_2 = 18var model_input_2 = [{ "message": "", role: "user" }]