跳到主要内容

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