Перейти до основного вмісту

Configuring Global Environment Variables in Node-RED

This guide explains how to use the "Set Global Configuration" flow. This is the most important setup step, as it provides all other flows (like the Opik Evaluation Harness and the Classic Test Agent) with the necessary credentials, URLs, and settings they need to operate.

Why This Flow is Important

Instead of hard-coding API keys or URLs into multiple different flows, we use Node-RED's global context. This is like a central storage area that any flow can access. This flow is designed to be the single source of truth for your entire project.

By using it, you only ever need to update your credentials in one place. This makes management simple, secure, and less prone to errors.

How the Flow Works

The flow is simple by design, ensuring it's easy to understand and use.

Set Global Configuration Flow

Triggers (Inject nodes): There are two ways the flow runs:

  • Set Globals on Deploy: This node is configured to run automatically, one second after you deploy your flows. This ensures your configuration is always active.
  • Manually Set Globals: You can click the button on this node at any time to re-apply the configuration without needing to redeploy.

Configuration (Change node): This is the only node you need to edit. It contains a list of rules that set each of the required global variables. All your keys, passwords, and URLs are stored here. You can download the Node-RED flow for this guide here. (Right-click and "Save link as..." to download)

Change Node Edit Panel

Verification (Function and Debug nodes): After the variables are set, a function node reads all the values back from the global context and a Debug node displays them in the debug sidebar. This gives you immediate visual confirmation that your configuration was loaded successfully.

How to Configure Your Environment

Follow these steps to set up your credentials.

Step 1: Locate the Configuration Node

In Node-RED, navigate to the tab named "Set Global Configuration".

Find the Change node labeled "EDIT ME: Configure Global Variables".

Step 2: Edit the Variables

Double-click on the "EDIT ME" node to open its configuration panel. You will see a list of rules. For each rule, update the value in the field to match your own environment settings.

Here is a description of each variable you need to set:

VariableDescriptionExample
openaiKeyRequired. Your secret API key from OpenAI. This is used for all LLM calls (e.g., GPT-4o) and for generating embeddings.sk-proj-xxxxxxxx...
chroma_linkRequired. The full network URL to your running ChromaDB vector database instance. This must be accessible from Node-RED.http://vectordb-service:8000
opik_urlRequired. The unique base URL for your personal Opik service.https://opik-5851-....tahsin.ubos.tech
opik_usernameRequired. The username for authenticating with your Opik service's private API.admin
opik_passwordRequired. The password corresponding to the Opik username.ch7kLaBj3156H6LxksElz8

Step 3: Deploy and Verify

After editing the values, click "Done" to close the panel.

Click the red "Deploy" button in the top-right corner of Node-RED.

The flow will run automatically. Check the Debug sidebar (on the right). You should see a message from the "Globals Set!" node containing all the variables you just configured. Verify that they are correct.

Your entire Node-RED environment is now correctly configured and ready to run the evaluation and testing flows.