Open AI prompt is reliable?

Problem: The open AI node is not responding as per the requirement. The prompt is the following:
Rulebook:

  1. Color Coding:
    1.1.If the pending is equals to 0, set row font color to Green.
    1.2. If the pending is equals to 1, set row font color to Red.

Based on the rulebook, convert the JSON into HTML table.
JSON: {{$json.appended_data}}

Respond with html code and not javascript.

The Open AI is responding like:
content: pending fabrics 0 0 0 1

The input json:

[
  {
    "appended_data": [
      [
        {
          "documentno": "110",
          "orderdate": "2023-11-13",
          "pending": 0
        }
      ],
      [
        {
          "documentno": "111",
          "orderdate": "2023-11-14",
          "pending": 0
        }
      ],
      [
        {
          "documentno": "112",
          "orderdate": "2023-11-18",
          "pending": 0
        }
      ],
      [
        {
          "documentno": "123",
          "orderdate": "2023-11-18",
          "pending": 1
        }
      ]
    ]

  }
]

output of open ai for the same prompt:
“content”: " pending_fabrics 0 0 0 0 "

Also, with every run, with the same input json and prompt, it returns different output.
Please tell me how the open ai node works really.

{
“meta”: {
“instanceId”: “073766742218d98f43cee5741416b15a791949637545e41b94fb21e19e7b4ecf”
},
“nodes”: [
{
“parameters”: {
“resource”: “chat”,
“prompt”: {
“messages”: [
{
“content”: "=Rulebook: \n1. Color Coding: \n1.1.If the pending_fabrics is equals to 0, set row font color to Green. \n1.2. If the pending_fabrics is equals to 1, set row font color to Red. \n\nBased on the rulebook, convert the JSON into HTML table.\nJSON: {{$json.appended_data}}\n\nRespond with html table not Javascript. "
}
]
},
“options”: {
“temperature”: 0.7
}
},
“id”: “25f1a0c0-fbac-46c6-bf7b-80bb2e074c51”,
“name”: “OpenAI”,
“type”: “n8n-nodes-base.openAi”,
“typeVersion”: 1,
“position”: [
1560,
320
],
“credentials”: {
“openAiApi”: {
“id”: “O2e5iVLJNfTQHsx4”,
“name”: “OpenAi account”
}
}
}
],
“connections”: {},
“pinData”: {}
}

  • n8n version: 1.21.1
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker self hosted
  • Operating system: Windows 7

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Ose_Verma, I am sorry you are having trouble.

The Open AI is responding like:
content: pending fabrics 0 0 0 1

This is probably caused by some versions of n8n trying to render some HTML in the output. The problem is fixed in more recent versions such as 1.25.0, so you might want to upgrade here.

v1.21.1

v1.25.0

Also, with every run, with the same input json and prompt, it returns different output.
Please tell me how the open ai node works really.

This would come down to how OpenAI itself works. n8n would simply take your input and send it to the OpenAI, then provide the result. You might want to read through the discussion in the OpenAI community itself about this, for example Coping with inconsistent results on identical inputs - API - OpenAI Developer Forum

2 Likes