{
  "orderPreparation": {
    "parameters": {
      "mistral_api_key": {
        "type": "String",
        "default": "\"<mistral-api-key>\"",
        "default1": "\"\""
      },
      "prompt_question": {
        "type": "String",
        "default": "\"which is the most sunny city?\"",
        "default1": "\"\""
      },
      "prompt_template": {
        "type": "String",
        "default": "\"# Get Weather\\\\n\\\\n## Instruction\\\\n\\\\nYou are looking for weather data.\\\\nYou must respond with a city name that matches the user's request.\\\\n\\\\n### Example Output\\\\n\\\\nPlain text: Name of a city\\\\nDo not use Markdown or any other formatting; use only a plain string.\\\\n\\\\n## User Prompt\\\\n\\\\n\"",
        "default1": "\"\""
      },
      "result_template": {
        "type": "String",
        "default": "\"# Return Weather as JSON\\\\n\\\\n## Instruction\\\\n\\\\nReturn the received weather data in JSON format.\\\\nUse a single line for the JSON Result.\\\\n### Example Output\\\\n\\\\nOnly Use the example fields and do not add more fields.\\\\n\\\\n{\\\\\\\"location\\\\\\\": \\\\\\\"London\\\\\\\", \\\\\\\"temperature\\\\\\\": \\\\\\\"24 C\\\\\\\"}\\\\n\\\\n## Weather Data\\\\n\"",
        "default1": "\"\""
      }
    },
    "allowUndeclared": false
  },
  "instructions": [
    {
      "TYPE": "Execute.Named",
      "jobName": "ask-city",
      "label": "ask-city"
    },
    {
      "TYPE": "Execute.Named",
      "jobName": "get-city-coordinates",
      "label": "get-city-coordinates"
    },
    {
      "TYPE": "Execute.Named",
      "jobName": "get-weather-data",
      "label": "get-weather-data"
    },
    {
      "TYPE": "Execute.Named",
      "jobName": "get-json-results",
      "label": "get-json-results"
    }
  ],
  "title": "Ask an AI model for a city and return current weather",
  "timeZone": "Europe/Berlin",
  "jobs": {
    "ask-city": {
      "agentName": "primaryAgent",
      "withSubagentClusterIdExpr": false,
      "executable": {
        "TYPE": "InternalExecutable",
        "className": "com.sos.jitl.jobs.rest.RESTClientJob",
        "internalType": "JITL",
        "jobArguments": {
          "template": "\"TEMPLATE\""
        },
        "arguments": {
          "request": "\"{\\n    \\\"endpoint\\\": \\\"https://api.mistral.ai/v1/conversations\\\",\\n    \\\"method\\\": \\\"POST\\\",\\n    \\\"headers\\\": [\\n        {\\n            \\\"key\\\": \\\"Content-Type\\\",\\n            \\\"value\\\": \\\"application/json\\\"\\n        },\\n        {\\n            \\\"key\\\": \\\"Authorization\\\",\\n            \\\"value\\\": \\\"Bearer ${mistral_api_key}\\\"\\n        }\\n    ],\\n    \\\"body\\\": {\\n        \\\"model\\\": \\\"mistral-small-latest\\\",\\n        \\\"instructions\\\": \\\"\\\",\\n        \\\"inputs\\\": [{ \\n            \\\"role\\\": \\\"user\\\", \\n            \\\"content\\\": \\\"${prompt_template} ${prompt_question}\\\"\\n        }],\\n        \\\"tools\\\": [],\\n        \\\"completion_args\\\": {\\n            \\\"temperature\\\": 0.7,\\n            \\\"max_tokens\\\": 2048,\\n            \\\"top_p\\\": 1\\n        }\\n    }\\n}\"",
          "return_variable": "\"[\\n  {\\n    \\\"name\\\": \\\"city\\\",\\n    \\\"path\\\": \\\".outputs[0].content | @uri || --raw-output\\\"\\n  }\\n]\""
        }
      },
      "skipIfNoAdmissionForOrderDay": false,
      "killAtEndOfAdmissionPeriod": false,
      "parallelism": 1,
      "graceTimeout": 1,
      "failOnErrWritten": false,
      "warnOnErrWritten": false,
      "title": "Get city from AI model processing user input",
      "isNotRestartable": false
    },
    "get-city-coordinates": {
      "agentName": "primaryAgent",
      "withSubagentClusterIdExpr": false,
      "executable": {
        "TYPE": "InternalExecutable",
        "className": "com.sos.jitl.jobs.rest.RESTClientJob",
        "internalType": "JITL",
        "arguments": {
          "request": "\"{\\n    \\\"endpoint\\\": \\\"https://geocoding-api.open-meteo.com/v1/search?count=1&name=${city}\\\",\\n    \\\"method\\\": \\\"GET\\\",\\n    \\\"headers\\\": [\\n        {\\n            \\\"key\\\": \\\"Content-Type\\\",\\n            \\\"value\\\": \\\"application/json\\\"\\n        }\\n    ],\\n    \\\"body\\\": {}\\n}\"",
          "return_variable": "\"[\\n  {\\n    \\\"name\\\": \\\"latitude\\\",\\n    \\\"path\\\": \\\".results[0].latitude || --raw-output\\\"\\n  },\\n  {\\n    \\\"name\\\": \\\"longitude\\\",\\n    \\\"path\\\": \\\".results[0].longitude || --raw-output\\\"\\n  }\\n]\""
        }
      },
      "skipIfNoAdmissionForOrderDay": false,
      "killAtEndOfAdmissionPeriod": false,
      "parallelism": 1,
      "graceTimeout": 1,
      "failOnErrWritten": false,
      "warnOnErrWritten": false,
      "title": "Get city coordinates: longitude, lattitude",
      "isNotRestartable": false
    },
    "get-weather-data": {
      "agentName": "primaryAgent",
      "withSubagentClusterIdExpr": false,
      "executable": {
        "TYPE": "InternalExecutable",
        "className": "com.sos.jitl.jobs.rest.RESTClientJob",
        "internalType": "JITL",
        "arguments": {
          "request": "\"{\\n    \\\"endpoint\\\": \\\"https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current=temperature_2m\\\",\\n    \\\"method\\\": \\\"GET\\\",\\n    \\\"headers\\\": [\\n        {\\n            \\\"key\\\": \\\"Content-Type\\\",\\n            \\\"value\\\": \\\"application/json\\\"\\n        }\\n    ],\\n    \\\"body\\\": {}\\n}\"",
          "return_variable": "\"[\\n  {\\n    \\\"name\\\": \\\"weather_data\\\",\\n    \\\"path\\\": \\\".current.temperature_2m || --raw-output\\\"\\n  }\\n]\""
        }
      },
      "skipIfNoAdmissionForOrderDay": false,
      "killAtEndOfAdmissionPeriod": false,
      "parallelism": 1,
      "graceTimeout": 1,
      "failOnErrWritten": false,
      "warnOnErrWritten": false,
      "title": "Get weather data for city",
      "isNotRestartable": false
    },
    "get-json-results": {
      "agentName": "primaryAgent",
      "withSubagentClusterIdExpr": false,
      "executable": {
        "TYPE": "InternalExecutable",
        "className": "com.sos.jitl.jobs.rest.RESTClientJob",
        "internalType": "JITL",
        "arguments": {
          "request": "\"{\\n    \\\"endpoint\\\": \\\"https://api.mistral.ai/v1/conversations\\\",\\n    \\\"method\\\": \\\"POST\\\",\\n    \\\"headers\\\": [\\n        {\\n            \\\"key\\\": \\\"Content-Type\\\",\\n            \\\"value\\\": \\\"application/json\\\"\\n        },\\n        {\\n            \\\"key\\\": \\\"Authorization\\\",\\n            \\\"value\\\": \\\"Bearer ${mistral_api_key}\\\"\\n        }\\n    ],\\n    \\\"body\\\": {\\n        \\\"model\\\": \\\"mistral-small-latest\\\",\\n        \\\"instructions\\\": \\\"\\\",\\n        \\\"inputs\\\": [{ \\n            \\\"role\\\": \\\"user\\\", \\n            \\\"content\\\": \\\"${result_template}\\\\ncity: ${city}\\\\n${weather_data}\\\" \\n        }],\\n        \\\"tools\\\": [],\\n        \\\"completion_args\\\": {\\n            \\\"temperature\\\": 0.7,\\n            \\\"max_tokens\\\": 2048,\\n            \\\"top_p\\\": 1\\n        }\\n    }\\n}\"",
          "return_variable": "\"[\\n  {\\n    \\\"name\\\": \\\"results\\\",\\n    \\\"path\\\": \\\".outputs[0].content || --raw-output\\\"\\n  }\\n]\""
        }
      },
      "skipIfNoAdmissionForOrderDay": false,
      "killAtEndOfAdmissionPeriod": false,
      "parallelism": 1,
      "graceTimeout": 1,
      "failOnErrWritten": false,
      "warnOnErrWritten": false,
      "title": "Generate results in JSON format from AI model",
      "isNotRestartable": false
    }
  }
}