diff --git a/404.html b/404.html index f6dca596a6..37728afa92 100644 --- a/404.html +++ b/404.html @@ -10,7 +10,7 @@ - +
diff --git a/Components/components-memories.html b/Components/components-memories.html index 261c8f2106..463bb0c0b9 100644 --- a/Components/components-memories.html +++ b/Components/components-memories.html @@ -10,7 +10,7 @@ - + diff --git a/Components/components-tools.html b/Components/components-tools.html index 08148526ce..24384ecf7e 100644 --- a/Components/components-tools.html +++ b/Components/components-tools.html @@ -10,7 +10,7 @@ - + diff --git a/agents-overview.html b/agents-overview.html index d03e42ac13..67900601af 100644 --- a/agents-overview.html +++ b/agents-overview.html @@ -10,7 +10,7 @@ - + diff --git a/agents-tool-calling-agent-component.html b/agents-tool-calling-agent-component.html index 4b392f8720..7c7848346e 100644 --- a/agents-tool-calling-agent-component.html +++ b/agents-tool-calling-agent-component.html @@ -10,7 +10,7 @@ - + diff --git a/assets/js/2efb9d3a.c4d2d014.js b/assets/js/2efb9d3a.c4d2d014.js new file mode 100644 index 0000000000..fe14ce6f7a --- /dev/null +++ b/assets/js/2efb9d3a.c4d2d014.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunklangflow_docs=self.webpackChunklangflow_docs||[]).push([[2691],{4441:(e,t,o)=>{o.r(t),o.d(t,{CH:()=>d,assets:()=>a,chCodeConfig:()=>p,contentTitle:()=>i,default:()=>y,frontMatter:()=>c,metadata:()=>l,toc:()=>h});var n=o(4848),s=o(8453),r=o(4754);const c={title:"Data & Message",sidebar_position:2,slug:"/guides-data-message"},i=void 0,l={id:"Guides/guides-data-message",title:"Data & Message",description:"In Langflow, the\xa0Data\xa0and\xa0Message\xa0objects serve as structured, functional representations of data that enhance the capabilities and reliability of the platform.",source:"@site/docs/Guides/guides-data-message.md",sourceDirName:"Guides",slug:"/guides-data-message",permalink:"/guides-data-message",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{title:"Data & Message",sidebar_position:2,slug:"/guides-data-message"},sidebar:"defaultSidebar",previous:{title:"Chat Memory",permalink:"/guides-chat-memory"},next:{title:"Workspace concepts",permalink:"/workspace-overview"}},a={},d={annotations:r.hk,Code:r.Cy},p={staticMediaQuery:"not screen, (max-width: 768px)",lineNumbers:!0,showCopyButton:!0,themeName:"github-dark"},h=[{value:"The Data Object",id:"e0d56e463d2f483bb1b5df09d88bf309",level:2},{value:"Creating a Data Object",id:"3540b7e651f74b558febebbe43380660",level:3},{value:"Message object attributes",id:"f4f17cad02a545068f407d515cbc2902",level:2}];function u(e){const t={code:"code",h2:"h2",h3:"h3",hr:"hr",li:"li",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return d||g("CH",!1),d.Code||g("CH.Code",!0),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:'[data-ch-theme="github-dark"] { --ch-t-colorScheme: dark;--ch-t-foreground: #c9d1d9;--ch-t-background: #0d1117;--ch-t-lighter-inlineBackground: #0d1117e6;--ch-t-editor-background: #0d1117;--ch-t-editor-foreground: #c9d1d9;--ch-t-editor-lineHighlightBackground: #6e76811a;--ch-t-editor-rangeHighlightBackground: #ffffff0b;--ch-t-editor-infoForeground: #3794FF;--ch-t-editor-selectionBackground: #264F78;--ch-t-focusBorder: #1f6feb;--ch-t-tab-activeBackground: #0d1117;--ch-t-tab-activeForeground: #c9d1d9;--ch-t-tab-inactiveBackground: #010409;--ch-t-tab-inactiveForeground: #8b949e;--ch-t-tab-border: #30363d;--ch-t-tab-activeBorder: #0d1117;--ch-t-editorGroup-border: #30363d;--ch-t-editorGroupHeader-tabsBackground: #010409;--ch-t-editorLineNumber-foreground: #6e7681;--ch-t-input-background: #0d1117;--ch-t-input-foreground: #c9d1d9;--ch-t-input-border: #30363d;--ch-t-icon-foreground: #8b949e;--ch-t-sideBar-background: #010409;--ch-t-sideBar-foreground: #c9d1d9;--ch-t-sideBar-border: #30363d;--ch-t-list-activeSelectionBackground: #6e768166;--ch-t-list-activeSelectionForeground: #c9d1d9;--ch-t-list-hoverBackground: #6e76811a;--ch-t-list-hoverForeground: #c9d1d9; }'}}),"\n",(0,n.jsxs)(t.p,{children:["In Langflow, the\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0and\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0objects serve as structured, functional representations of data that enhance the capabilities and reliability of the platform."]}),"\n",(0,n.jsx)(t.h2,{id:"e0d56e463d2f483bb1b5df09d88bf309",children:"The Data Object"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0object is a Pydantic model that serves as a container for storing and manipulating data. It carries\xa0",(0,n.jsx)(t.code,{children:"data"}),"\u2014a dictionary that can be accessed as attributes\u2014and uses\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0to specify which key in the dictionary should be considered the primary text content."]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Main Attributes:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"text_key"}),": Specifies the key to retrieve the primary text data."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"data"}),": A dictionary to store additional data."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"default_value"}),": default value when the\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0is not present in the\xa0",(0,n.jsx)(t.code,{children:"data"}),"\xa0dictionary."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,n.jsx)(t.h3,{id:"3540b7e651f74b558febebbe43380660",children:"Creating a Data Object"}),"\n",(0,n.jsxs)(t.p,{children:["You can create a\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0object by directly assigning key-value pairs to it. For example:"]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"from",props:{style:{color:"#FF7B72"}}},{content:" langflow.schema ",props:{style:{color:"#C9D1D9"}}},{content:"import",props:{style:{color:"#FF7B72"}}},{content:" Data",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Creating a Data object with specified key-value pairs",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"data ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Data(",props:{style:{color:"#C9D1D9"}}},{content:"text",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"my_string"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"bar",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:"3",props:{style:{color:"#79C0FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"foo",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"another_string"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Outputs:",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.text) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "my_string"',props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.bar) ",props:{style:{color:"#C9D1D9"}}},{content:"# Outputs: 3",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.foo) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "another_string"',props:{style:{color:"#8B949E"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0specifies which key in the\xa0",(0,n.jsx)(t.code,{children:"data"}),"\xa0dictionary should be considered the primary text content. The\xa0",(0,n.jsx)(t.code,{children:"default_value"}),"\xa0provides a fallback if the\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0is not present."]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"# Creating a Data object with a specific text_key and default_value",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"data ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Data(",props:{style:{color:"#C9D1D9"}}},{content:"data",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:"{",props:{style:{color:"#C9D1D9"}}},{content:'"title"',props:{style:{color:"#A5D6FF"}}},{content:": ",props:{style:{color:"#C9D1D9"}}},{content:'"Hello, World!"',props:{style:{color:"#A5D6FF"}}},{content:"}, ",props:{style:{color:"#C9D1D9"}}},{content:"text_key",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"content"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"default_value",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"No content available"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Accessing the primary text using text_key and default_value",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.get_text()) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "No content available" because "content" key is not in the data dictionary',props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Accessing data keys by calling the attribute directly",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.title) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "Hello, World!" because "title" key is in the data dictionary',props:{style:{color:"#8B949E"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["The ",(0,n.jsx)(t.code,{children:"Data"})," object is also convenient for visualization of outputs, since the output preview has visual elements to inspect data as a table and its cells as pop ups for basic types. The idea is to create a unified way to work and visualize complex information in Langflow."]}),"\n",(0,n.jsxs)(t.p,{children:["To receive ",(0,n.jsx)(t.code,{children:"Data"})," objects in a component input, you can use the ",(0,n.jsx)(t.code,{children:"DataInput"})," input type."]}),"\n",(0,n.jsx)(t.h2,{id:"f4f17cad02a545068f407d515cbc2902",children:"Message object attributes"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object extends the functionality of\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0and includes additional attributes and methods for chat interactions."]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.strong,{children:"Core message data:"})}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"text"}),": The main text content of the message"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"sender"}),': Identifier for the sender (e.g., "User" or "AI")']}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"sender_name"}),": Name of the sender"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"session_id"}),": Identifier for the chat session"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"timestamp"}),": Timestamp when the message was created (UTC)"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"flow_id"}),": Identifier for the flow"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"id"}),": Unique identifier for the message"]}),"\n"]}),"\n"]}),"\n",(0,n.jsxs)(t.li,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.strong,{children:"Content and files:"})}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"files"}),": List of files or images associated with the message"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"content_blocks"}),": List of structured content blocks"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"properties"}),": Additional properties including visual styling and source information"]}),"\n"]}),"\n"]}),"\n",(0,n.jsxs)(t.li,{children:["\n",(0,n.jsx)(t.p,{children:(0,n.jsx)(t.strong,{children:"Message state:"})}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"error"}),": Boolean indicating if there was an error"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"edit"}),": Boolean indicating if the message was edited"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"category"}),': Message category ("message", "error", "warning", "info")']}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object can be used to send, store, and manipulate chat messages within Langflow. You can create a\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object by directly assigning key-value pairs to it. For example:"]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"from",props:{style:{color:"#FF7B72"}}},{content:" langflow.schema.message ",props:{style:{color:"#C9D1D9"}}},{content:"import",props:{style:{color:"#FF7B72"}}},{content:" Message",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"message ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Message(",props:{style:{color:"#C9D1D9"}}},{content:"text",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"Hello, AI!"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"sender",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"User"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"sender_name",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"John Doe"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["To receive ",(0,n.jsx)(t.code,{children:"Message"})," objects in a component input, you can use the ",(0,n.jsx)(t.code,{children:"MessageInput"})," input type or ",(0,n.jsx)(t.code,{children:"MessageTextInput"})," when the goal is to extract just the ",(0,n.jsx)(t.code,{children:"text"})," field of the ",(0,n.jsx)(t.code,{children:"Message"})," object."]})]})}function y(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(u,{...e})}):u(e)}function g(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}}}]); \ No newline at end of file diff --git a/assets/js/2efb9d3a.ee124360.js b/assets/js/2efb9d3a.ee124360.js deleted file mode 100644 index 6349b3a014..0000000000 --- a/assets/js/2efb9d3a.ee124360.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunklangflow_docs=self.webpackChunklangflow_docs||[]).push([[2691],{4441:(e,t,o)=>{o.r(t),o.d(t,{CH:()=>d,assets:()=>i,chCodeConfig:()=>p,contentTitle:()=>a,default:()=>y,frontMatter:()=>r,metadata:()=>l,toc:()=>h});var n=o(4848),s=o(8453),c=o(4754);const r={title:"Data & Message",sidebar_position:2,slug:"/guides-data-message"},a=void 0,l={id:"Guides/guides-data-message",title:"Data & Message",description:"In Langflow, the\xa0Data\xa0and\xa0Message\xa0objects serve as structured, functional representations of data that enhance the capabilities and reliability of the platform.",source:"@site/docs/Guides/guides-data-message.md",sourceDirName:"Guides",slug:"/guides-data-message",permalink:"/guides-data-message",draft:!1,unlisted:!1,tags:[],version:"current",sidebarPosition:2,frontMatter:{title:"Data & Message",sidebar_position:2,slug:"/guides-data-message"},sidebar:"defaultSidebar",previous:{title:"Chat Memory",permalink:"/guides-chat-memory"},next:{title:"Workspace concepts",permalink:"/workspace-overview"}},i={},d={annotations:c.hk,Code:c.Cy},p={staticMediaQuery:"not screen, (max-width: 768px)",lineNumbers:!0,showCopyButton:!0,themeName:"github-dark"},h=[{value:"The Data Object",id:"e0d56e463d2f483bb1b5df09d88bf309",level:2},{value:"Creating a Data Object",id:"3540b7e651f74b558febebbe43380660",level:3},{value:"The Message Object",id:"f4f17cad02a545068f407d515cbc2902",level:2}];function u(e){const t={code:"code",h2:"h2",h3:"h3",hr:"hr",li:"li",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return d||g("CH",!1),d.Code||g("CH.Code",!0),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:'[data-ch-theme="github-dark"] { --ch-t-colorScheme: dark;--ch-t-foreground: #c9d1d9;--ch-t-background: #0d1117;--ch-t-lighter-inlineBackground: #0d1117e6;--ch-t-editor-background: #0d1117;--ch-t-editor-foreground: #c9d1d9;--ch-t-editor-lineHighlightBackground: #6e76811a;--ch-t-editor-rangeHighlightBackground: #ffffff0b;--ch-t-editor-infoForeground: #3794FF;--ch-t-editor-selectionBackground: #264F78;--ch-t-focusBorder: #1f6feb;--ch-t-tab-activeBackground: #0d1117;--ch-t-tab-activeForeground: #c9d1d9;--ch-t-tab-inactiveBackground: #010409;--ch-t-tab-inactiveForeground: #8b949e;--ch-t-tab-border: #30363d;--ch-t-tab-activeBorder: #0d1117;--ch-t-editorGroup-border: #30363d;--ch-t-editorGroupHeader-tabsBackground: #010409;--ch-t-editorLineNumber-foreground: #6e7681;--ch-t-input-background: #0d1117;--ch-t-input-foreground: #c9d1d9;--ch-t-input-border: #30363d;--ch-t-icon-foreground: #8b949e;--ch-t-sideBar-background: #010409;--ch-t-sideBar-foreground: #c9d1d9;--ch-t-sideBar-border: #30363d;--ch-t-list-activeSelectionBackground: #6e768166;--ch-t-list-activeSelectionForeground: #c9d1d9;--ch-t-list-hoverBackground: #6e76811a;--ch-t-list-hoverForeground: #c9d1d9; }'}}),"\n",(0,n.jsxs)(t.p,{children:["In Langflow, the\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0and\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0objects serve as structured, functional representations of data that enhance the capabilities and reliability of the platform."]}),"\n",(0,n.jsx)(t.h2,{id:"e0d56e463d2f483bb1b5df09d88bf309",children:"The Data Object"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0object is a Pydantic model that serves as a container for storing and manipulating data. It carries\xa0",(0,n.jsx)(t.code,{children:"data"}),"\u2014a dictionary that can be accessed as attributes\u2014and uses\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0to specify which key in the dictionary should be considered the primary text content."]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Main Attributes:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"text_key"}),": Specifies the key to retrieve the primary text data."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"data"}),": A dictionary to store additional data."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"default_value"}),": default value when the\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0is not present in the\xa0",(0,n.jsx)(t.code,{children:"data"}),"\xa0dictionary."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,n.jsx)(t.h3,{id:"3540b7e651f74b558febebbe43380660",children:"Creating a Data Object"}),"\n",(0,n.jsxs)(t.p,{children:["You can create a\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0object by directly assigning key-value pairs to it. For example:"]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"from",props:{style:{color:"#FF7B72"}}},{content:" langflow.schema ",props:{style:{color:"#C9D1D9"}}},{content:"import",props:{style:{color:"#FF7B72"}}},{content:" Data",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Creating a Data object with specified key-value pairs",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"data ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Data(",props:{style:{color:"#C9D1D9"}}},{content:"text",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"my_string"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"bar",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:"3",props:{style:{color:"#79C0FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"foo",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"another_string"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Outputs:",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.text) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "my_string"',props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.bar) ",props:{style:{color:"#C9D1D9"}}},{content:"# Outputs: 3",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.foo) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "another_string"',props:{style:{color:"#8B949E"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0specifies which key in the\xa0",(0,n.jsx)(t.code,{children:"data"}),"\xa0dictionary should be considered the primary text content. The\xa0",(0,n.jsx)(t.code,{children:"default_value"}),"\xa0provides a fallback if the\xa0",(0,n.jsx)(t.code,{children:"text_key"}),"\xa0is not present."]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"# Creating a Data object with a specific text_key and default_value",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"data ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Data(",props:{style:{color:"#C9D1D9"}}},{content:"data",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:"{",props:{style:{color:"#C9D1D9"}}},{content:'"title"',props:{style:{color:"#A5D6FF"}}},{content:": ",props:{style:{color:"#C9D1D9"}}},{content:'"Hello, World!"',props:{style:{color:"#A5D6FF"}}},{content:"}, ",props:{style:{color:"#C9D1D9"}}},{content:"text_key",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"content"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"default_value",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"No content available"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Accessing the primary text using text_key and default_value",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.get_text()) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "No content available" because "content" key is not in the data dictionary',props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"# Accessing data keys by calling the attribute directly",props:{style:{color:"#8B949E"}}}]},{tokens:[{content:"print",props:{style:{color:"#79C0FF"}}},{content:"(data.title) ",props:{style:{color:"#C9D1D9"}}},{content:'# Outputs: "Hello, World!" because "title" key is in the data dictionary',props:{style:{color:"#8B949E"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["The ",(0,n.jsx)(t.code,{children:"Data"})," object is also convenient for visualization of outputs, since the output preview has visual elements to inspect data as a table and its cells as pop ups for basic types. The idea is to create a unified way to work and visualize complex information in Langflow."]}),"\n",(0,n.jsxs)(t.p,{children:["To receive ",(0,n.jsx)(t.code,{children:"Data"})," objects in a component input, you can use the ",(0,n.jsx)(t.code,{children:"DataInput"})," input type."]}),"\n",(0,n.jsx)(t.h2,{id:"f4f17cad02a545068f407d515cbc2902",children:"The Message Object"}),"\n",(0,n.jsx)(t.hr,{}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object extends the functionality of\xa0",(0,n.jsx)(t.code,{children:"Data"}),"\xa0and includes additional attributes and methods for chat interactions."]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.strong,{children:"Main Attributes:"}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"text_key"}),": Key to retrieve the primary text data."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"text"}),": The main text content of the message."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"sender"}),': Identifier for the sender (e.g., "User" or "AI").']}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"sender_name"}),": Name of the sender."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"files"}),": List of files associated with the message."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"session_id"}),": Identifier for the chat session."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"timestamp"}),": Timestamp when the message was created."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"flow_id"}),": Identifier for the flow."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["The\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object can be used to send, store and manipulate chat messages within Langflow. You can create a\xa0",(0,n.jsx)(t.code,{children:"Message"}),"\xa0object by directly assigning key-value pairs to it. For example:"]}),"\n",(0,n.jsx)(d.Code,{codeConfig:p,northPanel:{tabs:[""],active:"",heightRatio:1},files:[{name:"",focus:"",code:{lines:[{tokens:[{content:"from",props:{style:{color:"#FF7B72"}}},{content:" langflow.schema.message ",props:{style:{color:"#C9D1D9"}}},{content:"import",props:{style:{color:"#FF7B72"}}},{content:" Message",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"",props:{style:{color:"#C9D1D9"}}}]},{tokens:[{content:"message ",props:{style:{color:"#C9D1D9"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:" Message(",props:{style:{color:"#C9D1D9"}}},{content:"text",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"Hello, AI!"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"sender",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"User"',props:{style:{color:"#A5D6FF"}}},{content:", ",props:{style:{color:"#C9D1D9"}}},{content:"sender_name",props:{style:{color:"#FFA657"}}},{content:"=",props:{style:{color:"#FF7B72"}}},{content:'"John Doe"',props:{style:{color:"#A5D6FF"}}},{content:")",props:{style:{color:"#C9D1D9"}}}]}],lang:"python"},annotations:[]}]}),"\n",(0,n.jsxs)(t.p,{children:["To receive ",(0,n.jsx)(t.code,{children:"Message"})," objects in a component input, you can use the ",(0,n.jsx)(t.code,{children:"MessageInput"})," input type or ",(0,n.jsx)(t.code,{children:"MessageTextInput"})," when the goal is to extract just the ",(0,n.jsx)(t.code,{children:"text"})," field of the ",(0,n.jsx)(t.code,{children:"Message"})," object."]})]})}function y(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(u,{...e})}):u(e)}function g(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}}}]); \ No newline at end of file diff --git a/assets/js/runtime~main.77159e8c.js b/assets/js/runtime~main.90766109.js similarity index 99% rename from assets/js/runtime~main.77159e8c.js rename to assets/js/runtime~main.90766109.js index ff9882b5d3..5b40dd7c03 100644 --- a/assets/js/runtime~main.77159e8c.js +++ b/assets/js/runtime~main.90766109.js @@ -1 +1 @@ -(()=>{"use strict";var e,a,f,c,d,t={},b={};function r(e){var a=b[e];if(void 0!==a)return a.exports;var f=b[e]={id:e,loaded:!1,exports:{}};return t[e].call(f.exports,f,f.exports,r),f.loaded=!0,f.exports}r.m=t,r.c=b,e=[],r.O=(a,f,c,d)=>{if(!f){var t=1/0;for(i=0;i
_10# Creating a Data object with a specific text_key and default_value_10data = Data(data={"title": "Hello, World!"}, text_key="content", default_value="No content available")_10_10# Accessing the primary text using text_key and default_value_10print(data.get_text()) # Outputs: "No content available" because "content" key is not in the data dictionary_10_10# Accessing data keys by calling the attribute directly_10print(data.title) # Outputs: "Hello, World!" because "title" key is in the data dictionary
The Data object is also convenient for visualization of outputs, since the output preview has visual elements to inspect data as a table and its cells as pop ups for basic types. The idea is to create a unified way to work and visualize complex information in Langflow.
To receive Data objects in a component input, you can use the DataInput input type.
The Message object extends the functionality of Data and includes additional attributes and methods for chat interactions.
Core message data:
text_key: Key to retrieve the primary text data.text: The main text content of the message.sender: Identifier for the sender (e.g., "User" or "AI").sender_name: Name of the sender.files: List of files associated with the message.session_id: Identifier for the chat session.timestamp: Timestamp when the message was created.flow_id: Identifier for the flow.text: The main text content of the messagesender: Identifier for the sender (e.g., "User" or "AI")sender_name: Name of the sendersession_id: Identifier for the chat sessiontimestamp: Timestamp when the message was created (UTC)flow_id: Identifier for the flowid: Unique identifier for the messageContent and files:
+files: List of files or images associated with the messagecontent_blocks: List of structured content blocksproperties: Additional properties including visual styling and source informationMessage state:
+error: Boolean indicating if there was an erroredit: Boolean indicating if the message was editedcategory: Message category ("message", "error", "warning", "info")The Message object can be used to send, store and manipulate chat messages within Langflow. You can create a Message object by directly assigning key-value pairs to it. For example:
The Message object can be used to send, store, and manipulate chat messages within Langflow. You can create a Message object by directly assigning key-value pairs to it. For example:
_10from langflow.schema.message import Message_10_10message = Message(text="Hello, AI!", sender="User", sender_name="John Doe")
To receive Message objects in a component input, you can use the MessageInput input type or MessageTextInput when the goal is to extract just the text field of the Message object.
To receive Message objects in a component input, you can use the MessageInput input type or MessageTextInput when the goal is to extract just the text field of the Message object.