Skip to main content

Comparison Pattern

Workflow Approach​

This section describes a reusable workflow pattern for comparing two independently obtained values. The core idea is always the same: collect two results, then compare them in a dedicated step. What changes across variants is how the comparison itself is performed.

The three variants are:

  • Common base comparison pattern
  • Pattern variant: comparison via another datapoint (non-LLM)
  • Pattern variant: comparison via LLM

All three share the same high-level structure and can be swapped without changing the upstream workflow.

Common base pattern – “Compare two instances”​

Two independent calls (A and B) produce values. These values are stored in the workflow context and then compared in a separate step. The comparison step is intentionally isolated so it can be replaced or upgraded later without touching the data collection logic.

Steps

  1. Collect A
    Call datapoint X, extract the relevant field, store it as valueA.
  2. Collect B
    Call datapoint X (or Y), extract the relevant field, store it as valueB.
  3. Compare
    Use a comparison task (or a third datapoint call) to decide which value is better / colder / cheaper / faster, etc.

Each phase has a single responsibility, which makes failures and retries much more predictable.

Example Structure: Generic pattern (workflow skeleton)

The generic skeleton shows the minimal wiring needed to support this pattern. It intentionally avoids domain-specific assumptions so it can be reused across many scenarios.

⚠️ This example is provided solely to illustrate the structural layout of a pattern and is not intended to be a functional implementation.

What to adapt:

  • source-datapoint-A / source-datapoint-B → your real datapoints

    • e.g. weather lookup, flight search, cost calculator
  • ${input.value} → the actual field you care about

    • e.g.

      • input.current_weather.temperature
      • input.price
      • input.duration

Base Pattern (Workflow Skeleton)

{
"id": "example-wf1-pattern-workflow-compare-two-values",
"type": "workflow",
"version": "0.0.1",
"workflow": {
"type": "temporal",
"definition": {
"do": [
{
"getA": {
"call": "olive",
"with": {
"datapoint": "source-datapoint-A",
"parameters": {
"city": "${root.cityA}"
}
}
}
},
{
"storeA": {
"set": {
"valueA": "${input.value}"
}
}
},
{
"getB": {
"call": "olive",
"with": {
"datapoint": "source-datapoint-B",
"parameters": {
"city": "${root.cityB}"
}
}
}
},
{
"storeB": {
"set": {
"valueB": "${input.value}"
}
}
},
{
"compareValues": {
"set": {
"comparisonResult": {
"winner": "${valueA < valueB ? \"A\" : \"B\"}",
"difference": "${$abs(valueA - valueB)}"
}
}
}
},
{
"echoResult": {
"call": "olive",
"with": {
"datapoint": "echo-datapoint",
"parameters": {
"result": "${comparisonResult}"
}
}
}
}
]
}
}
}

Pattern variant – comparison via third datapoint​

Sometimes you want the comparison to be handled by a separate datapoint.

Example Structure: comparison datapoint (numeric)

⚠️ This example is provided solely to illustrate the structural layout and is not intended to be a functional implementation.

In this variant, you simply replace the final step of the base pattern. Instead of comparing inline, the workflow delegates the comparison to the reusable datapoint.

The datapoint:

  • takes valueA and valueB as inputs
  • applies a simple comparison rule
  • returns a result describing if A or B is the bigger result

Example: Comparison Datapoint (numeric)

{
"id": "example-dp1-compare-numbers",
"type": "datapoint",
"version": "0.0.1",
"tags": ["comparison", "examples", "utility"],
"name": "Compare Two Numbers",
"datapoint": {
"type": "transform",
"transform": "${ input.a < input.b ? \"A\" : \"B\" }"
}
}

Swap the last part of the base pattern with:

Example: Workflow tail using non-LLM comparator

{
"compareValuesWithDatapoint": {
"call": "olive",
"with": {
"datapoint": "example-dp1-compare-numbers",
"parameters": {
"a": "${valueA}",
"b": "${valueB}"
}
}
}
}

Pattern variant – comparison via LLM datapoint​

This variant keeps the same structure as the base pattern, but delegates phase 3 to a comparison datapoint backed by an LLM.

This is especially useful when:

  • the values are complex objects, not just numbers
  • the comparison criteria are fuzzy or contextual
  • you want a human-readable explanation, not just a boolean result

Example Structure: comparison datapoint (LLM)

⚠️ This example is provided solely to illustrate the structural layout and is not intended to be a functional implementation.

Here, the compareValues + echoResult part of the base pattern is replaced with a single LLM-backed comparison step.

The LLM-based comparison datapoint:

  • receives valueA and valueB (often as structured JSON)
  • applies natural-language reasoning
  • returns a summarized judgment, optionally with rationale

Example: Comparison Datapoint (LLM)

{
"id": "example-dp2-compare-with-llm",
"type": "datapoint",
"version": "0.0.1",
"tags": [
"pattern",
"comparison",
"llm"
],
"name": "Compare Two Values (LLM)",
"datapoint": {
"type": "prompt",
"prompt": {
"provider": "openai",
"model": "gpt-5-nano",
"systemprompt": "You compare two values according to a given criterion. Decide which option is better and explain your reasoning briefly and clearly.\n\nCriterion:\n${input.criterion}\n\nValue A:\n${input.valueA}\n\nValue B:\n${input.valueB}\n\nReturn your answer in 2–3 sentences."
},
"auth": "example-a1-openai-chatbot-key"
}
}

Replace the compareValues + echoResult part of the base pattern with:

Example: Workflow tail using LLM comparator

{
"compareValuesWithLLM": {
"call": "olive",
"with": {
"datapoint": "example-dp2-compare-with-llm",
"parameters": {
"criterion": "${root.criterion}",
"valueA": "${valueA}",
"valueB": "${valueB}"
}
}
}
}

Simple Number Comparison Example - Compare Weather for Two Cities​

In this example, we compare which of two cities is colder using live weather data.
The workflow:

  • Calls the same weather datapoint twice (for City A and City B)
  • Stores both temperatures in workflow variables
  • Compares them with a simple numeric expression
  • Returns the colder city and the temperature difference

What we learn

  • Calling the same datapoint multiple times with different parameters
  • Using set to store intermediate values (tempA, tempB)
  • Doing a simple number comparison inside the workflow

Weather HTTP datapoint

We use the free Open-Meteo API and create a datapoint to fetch the weather data.

Weather HTTP Datapoint

{
"id": "weathercomp-dp1-get-temperature",
"type": "datapoint",
"version": "1.0.0",
"name": "weathercomp-dp1-get-temperature",
"displayName": "weathercomp-dp1-get-temperature",
"tags": [
"example",
"simple-example",
"scenario-weathercomp",
"scenario-example-weathercomp"
],
"description": "Get Current Temperature (Open-Meteo)",
"datapoint": {
"type": "http",
"http": {
"url": "https://api.open-meteo.com/v1/forecast?latitude=${input.lat}&longitude=${input.lon}&current_weather=true",
"method": "GET",
"headers": {
"content-type": "application/json"
}
}
}
}

Workflow: Compare Two Temperatures

Create a workflow which compares the weather in two different cities.

ID: weathercomp-wf1-compare-temperatures

This workflow:

  • Calls the weather datapoint twice
  • Saves both temperatures
  • Compares them directly
  • Returns a simple JSON result

Comparison Workflow

{
"id": "weathercomp-wf1-compare-temperatures",
"name": "weathercomp-wf1-compare-temperatures",
"type": "workflow",
"version": "0.0.1",
"displayName": "weathercomp-wf1-compare-temperatures",
"description": "Example workflow that retrieves current temperature data for two cities via a weather datapoint, stores the intermediate values using set tasks, computes which city is colder and the absolute temperature difference, and outputs the comparison result via an echo datapoint.",
"tags": [
"example",
"simple-example",
"scenario-weathercomp",
"scenario-example-weathercomp"
],
"workflow": {
"type": "temporal",
"definition": {
"do": [
{
"getCityAWeather": {
"call": "olive",
"with": {
"datapoint": "weathercomp-dp1-get-temperature",
"parameters": {
"lat": "${root.cityA.lat}",
"lon": "${root.cityA.lon}"
}
}
}
},
{
"storeCityATemp": {
"set": {
"tempA": "${input.current_weather.temperature}"
}
}
},
{
"getCityBWeather": {
"call": "olive",
"with": {
"datapoint": "weathercomp-dp1-get-temperature",
"parameters": {
"lat": "${root.cityB.lat}",
"lon": "${root.cityB.lon}"
}
}
}
},
{
"storeCityBTemp": {
"set": {
"tempB": "${input.current_weather.temperature}"
}
}
},
{
"compareTemperatures": {
"set": {
"colderCity": {
"name": "${tempA < tempB ? root.cityA.name : root.cityB.name}",
"difference": "${$abs(tempA - tempB)}"
}
}
}
},
{
"echoResult": {
"call": "olive",
"with": {
"datapoint": "postman-dp-http-postman-post-placeholder",
"parameters": {
"result": "${colderCity}"
}
}
}
}
]
}
}
}

How to trigger the workflow via data-orchestrator:

Request Input

{
"id": "weathercomp-wf1-compare-temperatures",
"input": {
"cityA": { "name": "Vienna", "lat": 48.21, "lon": 16.37 },
"cityB": { "name": "Berlin", "lat": 52.52, "lon": 13.40 }
}
}

Connector Approach​

Pattern variant – comparison via Connector​

In some cases, a full workflow definition is unnecessary. If the comparison logic is purely sequential and does not require branching, retries, or complex state handling, the same pattern can be expressed more compactly using a Connector.

A connector represents a linear chain of datapoint calls, where each step consumes the output of the previous one. This approach is especially useful when:

  • the comparison logic is simple and linear
  • you want a compact, reusable comparison pipeline
  • you do not need workflow-level control constructs
  • you want to expose the comparison as a single callable unit

Conceptually, the pattern remains unchanged:

  1. Collect value A
  2. Collect value B
  3. Compare A and B

Only the modeling construct changes.

Example Structure: Comparison via Connector (LLM-based)

⚠️ This example is provided solely to illustrate the structural layout and is not intended to be a functional implementation.

In this example, the connector:

  • calls two source datapoints to obtain values
  • forwards both results into a Prompt-based comparison datapoint
  • returns the LLM’s comparison result directly

Base Pattern (Connector Skeleton)

{
"id": "example-c1-compare-two-values-connector",
"type": "connector",
"version": "0.0.1",
"tags": ["pattern", "comparison", "connector"],
"name": "Compare Two Values (Connector)",
"connector": {
"elements": [
{
"ref": "getA",
"element": "example-dp1-source-datapoint-A",
"parameters": {
"input": "${root.inputA}"
}
},
{
"ref": "getB",
"element": "example-dp2-source-datapoint-B",
"parameters": {
"input": "${root.inputB}"
}
},
{
"element": "example-dp2-compare-with-llm",
"parameters": {
"criterion": "${root.criterion}",
"valueA": "${ref.getA}",
"valueB": "${ref.getB}"
}
}
]
}
}