[{"data":1,"prerenderedAt":179},["ShallowReactive",2],{"blueprint-\u002Fblueprints\u002Fai\u002Fllm-chat-agent":3},{"id":4,"title":5,"author":6,"blueprintId":7,"body":8,"description":168,"extension":169,"image":124,"meta":170,"navigation":18,"path":171,"seo":172,"stem":173,"tags":174,"updated":177,"__hash__":178},"blueprints\u002Fblueprints\u002Fai\u002Fllm-chat-agent.md","OpenAI (LLM) Chat Agent",null,"9Znmk7maql",{"type":9,"value":10,"toc":153},"minimark",[11,19,22,27,32,43,46,50,59,63,66,70,81,84,88,96,99,109,112,115,119,127,130,134,137,140,146],[12,13,14],"p",{},[15,16],"video",{"src":17,"controls":18},"https:\u002F\u002Fwebsite-data.s3.eu-west-1.amazonaws.com\u002FBlueprint+-+Open+AI+Chat.mp4",true,[12,20,21],{},"A collection of starter flows to help you get up and running with training and running your own LLM chat agents within Node-RED.",[23,24,26],"h2",{"id":25},"setup","Setup",[28,29,31],"h3",{"id":30},"openai-api-key","OpenAI API Key",[12,33,34,35,42],{},"The OpenAI API key is required to use the OpenAI agent. To get an API key, you can sign up to OpenAI and create a new API key ",[36,37,41],"a",{"href":38,"rel":39},"https:\u002F\u002Fplatform.openai.com\u002Fapi-keys",[40],"nofollow","here",".",[12,44,45],{},"Once you have an API key, double-click on the \"OpenAI: Get Reply\" node in the \"Chat - Open AI\" flow, then \"Edit\" the \"Service Host\" field. Paste your API Key into the \"API Key\" field.",[28,47,49],{"id":48},"openai-organization-id","OpenAI Organization ID",[12,51,52,53,58],{},"You will also need your Organization ID, which you can find in the ",[36,54,57],{"href":55,"rel":56},"https:\u002F\u002Fplatform.openai.com\u002Fsettings\u002Forganization\u002Fgeneral",[40],"Open AI Organization Settings",". Paste this into the \"Organization ID\" field in the \"Service Host\" config node.",[23,60,62],{"id":61},"examples","Examples",[12,64,65],{},"The examples included are as follows:",[28,67,69],{"id":68},"hardcoded-responses","Hardcoded Responses",[12,71,72,78],{},[73,74],"img",{"alt":75,"dataZoomable":76,"src":77},"Screenshot of the Data Visualisation example","","\u002Fblueprints\u002Fai\u002Fllm-chat-agent\u002Fimages\u002Fscreenshot-hardcoded.png",[79,80,75],"em",{},[12,82,83],{},"The intention of this example is to get your familiar with the workflow of data in and out of the Chat Widget. it does not use OpenAI or any LLM Agent to reply, but provides you with some simple examples with which you can control the state of the conversational interface.",[28,85,87],{"id":86},"open-ai-integration","Open AI Integration",[12,89,90,94],{},[73,91],{"alt":92,"dataZoomable":76,"src":93},"Screenshot of a Dashboard with a Chat Widget to interface with an OpenAI Agent","\u002Fblueprints\u002Fai\u002Fllm-chat-agent\u002Fimages\u002Fscreenshot-openai-integration.png",[79,95,92],{},[12,97,98],{},"This demonstration show how you can use setup \"prompts\" to train an OpenAI Agent. In this case, we have prompted the agent with:",[100,101,106],"pre",{"className":102,"code":104,"language":105},[103],"language-text","You are an assistant that is an expert in Node-RED\nYou do not use emojis\nYou should only reply with plain text\n","text",[107,108,104],"code",{"__ignoreMap":76},[12,110,111],{},"As such, the agent will only reply with plain text, not use emojis, and reply with the context that questions should be about Node-RED.",[12,113,114],{},"You can overwrite the setup prompts in the \"Define Setup Prompts\" template node in order to prime the agent as you wish.",[28,116,118],{"id":117},"worldmap-integration","Worldmap Integration",[12,120,121,125],{},[73,122],{"alt":123,"dataZoomable":76,"src":124},"Screenshot of a Dashboard with a Chat interface to an OpenAI Agent, which integrates with a Worldmap to display location information","\u002Fblueprints\u002Fai\u002Fllm-chat-agent\u002Fimages\u002Fscreenshot-geography.png",[79,126,123],{},[12,128,129],{},"In this example we demonstrate how you can use the OpenAI agent to respond with more than just text in a chat interface. This flow utilises the power of Node-RED's flow editor to wire OpenAi responses to other widgets, specifically a Worldmap, which can be used to show geographical data based on the response from the OpenAI agent.",[23,131,133],{"id":132},"customizing-the-agents","Customizing the Agents",[12,135,136],{},"For both the \"Open AI Integration\" and \"Worldmap Integration\" examples, the agent is \"trained\" with prompts. These prompts are defined in the \"Define Setup Prompts\" template node found in each flow.",[12,138,139],{},"For example, the worldmap example uses the following prompt:",[100,141,144],{"className":142,"code":143,"language":105},[103],"You are an assistant that provides information about places around the world.\nWhen you respond, you should provide a JSON message.\nThe JSON message should ahve two properties: 'text' and 'location'.\nThe 'text' property should include a text-based response to the user's query.\nIf your answer includes information about a location, then include the latitude (as the property 'lat') and longitude (as the property 'lon') of that place in the 'location' field, with a 'name' field detailing the name of that location, if there is no location mentioned then leave it null.\n",[107,145,143],{"__ignoreMap":76},[12,147,148,149,152],{},"The rest of the \"Setup\" flow parses this template, and formats them for the OpenAI API, and stores the prompt in ",[107,150,151],{},"flow.prompts",". These prompts are then merged with the user's conversation in the \"Add Message to History\" function node.",{"title":76,"searchDepth":154,"depth":154,"links":155},4,[156,162,167],{"id":25,"depth":157,"text":26,"children":158},2,[159,161],{"id":30,"depth":160,"text":31},3,{"id":48,"depth":160,"text":49},{"id":61,"depth":157,"text":62,"children":163},[164,165,166],{"id":68,"depth":160,"text":69},{"id":86,"depth":160,"text":87},{"id":117,"depth":160,"text":118},{"id":132,"depth":157,"text":133},"A collection of examples to showcase how you can integrate LLM chat agents into your Node-RED flows.","md",{},"\u002Fblueprints\u002Fai\u002Fllm-chat-agent",{"title":5,"description":168},"blueprints\u002Fai\u002Fllm-chat-agent",[175,176],"blueprints","ai","2025-06-04 16:20:02 +0100","RIlCvO0LuJPtI4dpjnkYtMGJgm17P8tYkGeGxpWXULM",1789640807709]