AIMC Code icon

AIMC Code

Execute JavaScript with a curated toolkit of libraries.

AIMC Code

AI-generated

Summary

Execute arbitrary JavaScript or Python code with a built-in toolkit of libraries.

Inputs

  • language (required) — Programming language to use; either 'javascript' or 'python'.
  • mode (required) — Execution mode; 'runOnceForAllItems' processes the whole batch at once, 'runOnceForEachItem' processes each input item individually.
  • timeoutSeconds (required) — Maximum execution time in seconds (1‑300).
  • aiConnectMode — Enable AI connector inputs for models, tools, memory, and more.
  • aiConnections — Fixed-collection of AI connection configurations; each defines a type (e.g., 'ai_languageModel') and optional maxConnections.
  • code (required) — JavaScript code to run when language is 'javascript'; must be non-empty.
  • pythonCode (required) — Python code to run when language is 'python'; must set a variable named result as the output.
  • pythonPath — Path to the Python executable (default: 'python3').
  • pythonPackages — Comma-separated list of Python packages to auto-install if pythonAutoInstall is enabled.
  • pythonAutoInstall — When true, automatically install missing Python packages before running the script.

Output shape

an array of result objects

The returned array contains one element per processed item when mode is runOnceForEachItem; otherwise it contains a single element representing the batch result. The exact fields of each object are defined by the code you provide.

Examples

Example 1: Transform a list of product records using JavaScript and return enhanced data.

Language: javascript; Mode: runOnceForEachItem; Timeout: 30; Code: // add a processedAt field

Example 2: Count items and return the first item using Python.

Language: python; Mode: runOnceForAllItems; PythonCode: result = {"count": len(items), "first": items[0] if items else None}; PythonPath: python3; Auto-install: false

Example 3: Use an AI language model connection to enrich each document.

Language: javascript; Mode: runOnceForEachItem; AI Connect Mode: true; AI Connections: input (type: ai_languageModel); Code: // use ai.languageModel to call an LLM

Links

Discussion