跳到主要內容

AI 驅動文件

您想了解什麼?

如何在 Node-RED 中使用 ChatGPT

This deep dive demonstrates how to use ChatGPT with Node‑RED.


注意事項​

  • All Block Outputs 包含在觸發影象後輸出的所有資訊。

All Block Output node

  • 從 All Block Outputs 中複製除錯輸出。

Copy the All Block Outputs debug value

All Block Outputs​

此節點在相機每次捕獲後輸出資料,幷包含所有 AI 塊資料。資料以 JSON 物件的形式呈現。資料包括以下內容:

Payload FieldTypeDescription
payload.capture_idinteger此次捕獲的捕獲 ID
payload.recipe_idinteger此配方的配方 ID
payload.camera_idstring此相機的唯一字串識別符號
payload.inspection_idinteger每次檢查遞增的 16 位整數
payload.inspection_timestring每次檢查的捕獲的 ISO 8601 格式時間戳
payload.image_urlstring捕獲影象的 HTTP URL(jpg)
payload.alignment.successboolean對齊的部件是否成功
payload.alignment.center_location_xinteger對齊部件的中心位置 x
payload.alignment.center_location_yinteger對齊部件的中心位置 y
payload.alignment.confidencefloat (0-1)對齊的置信度

ChatGPT/Gemini/Copilot​

  • 輸入提示:“Here is the Input I have from Node Red : 在此插入複製的值。輸入您希望它失敗的提示並返回 msg.payload 為布林值 True 或 False”

ChatGPT Prompt Screen

示例​

  • 在這裡,我們教 AI 查詢安裝板上的孔。

Example annotation of mounting plate

  • 從 Node-RED 的 debug 塊中複製值,並將其貼上到 ChatGPT 中,使用以下示例提示。
    • “Here is the Input I have from Node Red : 在此插入複製的值。如果孔少於 11 個,我希望相機失敗,並返回 msg.payload 為布林值 True 或 False”

Example prompt

  • 檢視 function 塊並閱讀邏輯上的註釋。
  • 檢視它是否在做正確的事情(所要求的),如果是,請複製它給你的程式碼。
  • 從節點中獲取一個 function 節點,並將其連線到 Inspection Pass/Fail 塊。

Example of function block added to flow

Example ChatGPT window with function node code

  • 複製 function 塊中的程式碼,確保所有節點正確連線,然後點選 Deploy。

Example screenshot showing number of blobs

Example Edit function node window

Deploy button