-
Notifications
You must be signed in to change notification settings - Fork 3
/
Zoom_Astra_RAG_GenAI_Flow.json
1 lines (1 loc) · 112 KB
/
Zoom_Astra_RAG_GenAI_Flow.json
1
{"id":"e5743d07-5b04-4e7a-a3f3-2daf19e22953","data":{"nodes":[{"data":{"description":"Get chat inputs from the Playground.","display_name":"Chat Input","id":"ChatInput-c2hnf","node":{"template":{"_type":"Component","files":{"trace_as_metadata":true,"file_path":"","fileTypes":["txt","md","mdx","csv","json","yaml","yml","xml","html","htm","pdf","docx","py","sh","sql","js","ts","tsx","jpg","jpeg","png","bmp","image"],"list":true,"required":false,"placeholder":"","show":true,"name":"files","value":"","display_name":"Files","advanced":true,"dynamic":false,"info":"Files to be sent with the message.","title_case":false,"type":"file","_input_type":"FileInput"},"background_color":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"background_color","value":"","display_name":"Background Color","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The background color of the icon.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"chat_icon":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"chat_icon","value":"","display_name":"Icon","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The icon of the message.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.base.data.utils import IMG_FILE_TYPES, TEXT_FILE_TYPES\nfrom langflow.base.io.chat import ChatComponent\nfrom langflow.inputs import BoolInput\nfrom langflow.io import DropdownInput, FileInput, MessageTextInput, MultilineInput, Output\nfrom langflow.schema.message import Message\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_USER, MESSAGE_SENDER_USER\n\n\nclass ChatInput(ChatComponent):\n display_name = \"Chat Input\"\n description = \"Get chat inputs from the Playground.\"\n icon = \"MessagesSquare\"\n name = \"ChatInput\"\n\n inputs = [\n MultilineInput(\n name=\"input_value\",\n display_name=\"Text\",\n value=\"\",\n info=\"Message to be passed as input.\",\n ),\n BoolInput(\n name=\"should_store_message\",\n display_name=\"Store Messages\",\n info=\"Store the message in the history.\",\n value=True,\n advanced=True,\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[MESSAGE_SENDER_AI, MESSAGE_SENDER_USER],\n value=MESSAGE_SENDER_USER,\n info=\"Type of sender.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=MESSAGE_SENDER_NAME_USER,\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n advanced=True,\n ),\n FileInput(\n name=\"files\",\n display_name=\"Files\",\n file_types=TEXT_FILE_TYPES + IMG_FILE_TYPES,\n info=\"Files to be sent with the message.\",\n advanced=True,\n is_list=True,\n ),\n MessageTextInput(\n name=\"background_color\",\n display_name=\"Background Color\",\n info=\"The background color of the icon.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"chat_icon\",\n display_name=\"Icon\",\n info=\"The icon of the message.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"text_color\",\n display_name=\"Text Color\",\n info=\"The text color of the name\",\n advanced=True,\n ),\n ]\n outputs = [\n Output(display_name=\"Message\", name=\"message\", method=\"message_response\"),\n ]\n\n def message_response(self) -> Message:\n _background_color = self.background_color\n _text_color = self.text_color\n _icon = self.chat_icon\n message = Message(\n text=self.input_value,\n sender=self.sender,\n sender_name=self.sender_name,\n session_id=self.session_id,\n files=self.files,\n properties={\"background_color\": _background_color, \"text_color\": _text_color, \"icon\": _icon},\n )\n if self.session_id and isinstance(message, Message) and self.should_store_message:\n stored_message = self.send_message(\n message,\n )\n self.message.value = stored_message\n message = stored_message\n\n self.status = message\n return message\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"input_value":{"tool_mode":false,"trace_as_input":true,"multiline":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"input_value","value":"What is else Ojus working on?","display_name":"Text","advanced":false,"input_types":["Message"],"dynamic":false,"info":"Message to be passed as input.","title_case":false,"type":"str","_input_type":"MultilineInput"},"sender":{"tool_mode":false,"trace_as_metadata":true,"options":["Machine","User"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"sender","value":"User","display_name":"Sender Type","advanced":true,"dynamic":false,"info":"Type of sender.","title_case":false,"type":"str","_input_type":"DropdownInput"},"sender_name":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender_name","value":"User","display_name":"Sender Name","advanced":true,"input_types":["Message"],"dynamic":false,"info":"Name of the sender.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"session_id":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"should_store_message":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"should_store_message","value":true,"display_name":"Store Messages","advanced":true,"dynamic":false,"info":"Store the message in the history.","title_case":false,"type":"bool","_input_type":"BoolInput"},"text_color":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"text_color","value":"","display_name":"Text Color","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The text color of the name","title_case":false,"type":"str","_input_type":"MessageTextInput"}},"description":"Get chat inputs from the Playground.","icon":"MessagesSquare","base_classes":["Message"],"display_name":"Chat Input","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"message","display_name":"Message","method":"message_response","value":"__UNDEFINED__","cache":true}],"field_order":["input_value","should_store_message","sender","sender_name","session_id","files","background_color","chat_icon","text_color"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"type":"ChatInput"},"dragging":false,"height":319,"id":"ChatInput-c2hnf","position":{"x":727.9858044920961,"y":728.4070660049956},"positionAbsolute":{"x":727.9858044920961,"y":728.4070660049956},"selected":false,"type":"genericNode","width":320},{"data":{"description":"Convert Data into plain text following a specified template.","display_name":"Parse Data","id":"ParseData-wVfAN","node":{"template":{"_type":"Component","data":{"trace_as_metadata":true,"list":false,"trace_as_input":true,"required":false,"placeholder":"","show":true,"name":"data","value":"","display_name":"Data","advanced":false,"input_types":["Data"],"dynamic":false,"info":"The data to convert to text.","title_case":false,"type":"other","_input_type":"DataInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.custom import Component\nfrom langflow.helpers.data import data_to_text\nfrom langflow.io import DataInput, MultilineInput, Output, StrInput\nfrom langflow.schema.message import Message\n\n\nclass ParseDataComponent(Component):\n display_name = \"Parse Data\"\n description = \"Convert Data into plain text following a specified template.\"\n icon = \"braces\"\n name = \"ParseData\"\n\n inputs = [\n DataInput(name=\"data\", display_name=\"Data\", info=\"The data to convert to text.\"),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. \"\n \"It can contain the keys {text}, {data} or any other key in the Data.\",\n value=\"{text}\",\n ),\n StrInput(name=\"sep\", display_name=\"Separator\", advanced=True, value=\"\\n\"),\n ]\n\n outputs = [\n Output(display_name=\"Text\", name=\"text\", method=\"parse_data\"),\n ]\n\n def parse_data(self) -> Message:\n data = self.data if isinstance(self.data, list) else [self.data]\n template = self.template\n\n result_string = data_to_text(template, data, sep=self.sep)\n self.status = result_string\n return Message(text=result_string)\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"sep":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sep","value":"\n","display_name":"Separator","advanced":true,"dynamic":false,"info":"","title_case":false,"type":"str","_input_type":"StrInput"},"template":{"trace_as_input":true,"multiline":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"template","value":"{text}","display_name":"Template","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The template to use for formatting the data. It can contain the keys {text}, {data} or any other key in the Data.","title_case":false,"type":"str","_input_type":"MultilineInput"}},"description":"Convert Data into plain text following a specified template.","icon":"braces","base_classes":["Message"],"display_name":"Parse Data","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"text","display_name":"Text","method":"parse_data","value":"__UNDEFINED__","cache":true}],"field_order":["data","template","sep"],"beta":false,"edited":false,"metadata":{},"lf_version":"1.1.0"},"type":"ParseData"},"dragging":false,"height":301,"id":"ParseData-wVfAN","position":{"x":1672.3948339161516,"y":731.4098865111536},"positionAbsolute":{"x":1672.3948339161516,"y":731.4098865111536},"selected":false,"type":"genericNode","width":320},{"data":{"description":"Create a prompt template with dynamic variables.","display_name":"Prompt","id":"Prompt-pe8Ic","node":{"template":{"_type":"Component","code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.base.prompts.api_utils import process_prompt_template\nfrom langflow.custom import Component\nfrom langflow.inputs.inputs import DefaultPromptField\nfrom langflow.io import Output, PromptInput\nfrom langflow.schema.message import Message\nfrom langflow.template.utils import update_template_values\n\n\nclass PromptComponent(Component):\n display_name: str = \"Prompt\"\n description: str = \"Create a prompt template with dynamic variables.\"\n icon = \"prompts\"\n trace_type = \"prompt\"\n name = \"Prompt\"\n\n inputs = [\n PromptInput(name=\"template\", display_name=\"Template\"),\n ]\n\n outputs = [\n Output(display_name=\"Prompt Message\", name=\"prompt\", method=\"build_prompt\"),\n ]\n\n async def build_prompt(self) -> Message:\n prompt = Message.from_template(**self._attributes)\n self.status = prompt.text\n return prompt\n\n def _update_template(self, frontend_node: dict):\n prompt_template = frontend_node[\"template\"][\"template\"][\"value\"]\n custom_fields = frontend_node[\"custom_fields\"]\n frontend_node_template = frontend_node[\"template\"]\n _ = process_prompt_template(\n template=prompt_template,\n name=\"template\",\n custom_fields=custom_fields,\n frontend_node_template=frontend_node_template,\n )\n return frontend_node\n\n def post_code_processing(self, new_frontend_node: dict, current_frontend_node: dict):\n \"\"\"This function is called after the code validation is done.\"\"\"\n frontend_node = super().post_code_processing(new_frontend_node, current_frontend_node)\n template = frontend_node[\"template\"][\"template\"][\"value\"]\n # Kept it duplicated for backwards compatibility\n _ = process_prompt_template(\n template=template,\n name=\"template\",\n custom_fields=frontend_node[\"custom_fields\"],\n frontend_node_template=frontend_node[\"template\"],\n )\n # Now that template is updated, we need to grab any values that were set in the current_frontend_node\n # and update the frontend_node with those values\n update_template_values(new_template=frontend_node, previous_template=current_frontend_node[\"template\"])\n return frontend_node\n\n def _get_fallback_input(self, **kwargs):\n return DefaultPromptField(**kwargs)\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"template":{"tool_mode":false,"trace_as_input":true,"list":false,"required":false,"placeholder":"","show":true,"name":"template","value":"Chat History:\n<chat_history>\n{chat_history}\n</chat_history>\n\nContext:\n<context>\n{context}\n</context>\n\n- You are a knowledgeable and helpful AI assistant.\n- Focus on the context: Prioritize accuracy by thoroughly reviewing and referencing the provided context.\n- Use the chat history only to understand the flow of the conversation. The context takes precedence when answering, bit if asked, use the chat history to answer questions as well.\n\nImportant!\n- Provide only 1 sentence max unless asked otherwise.\n- Be succinct unless asked for more detailed information.\n- Do not hallucinate any information. Answer strictly based on the chat history and context.\n- Format the output to be easily readable. Use line breaks and spacing to emphasize key points.\n\nQuestion:\n{question}\n\nAnswer:","display_name":"Template","advanced":false,"dynamic":false,"info":"","title_case":false,"type":"prompt","_input_type":"PromptInput","load_from_db":false},"chat_history":{"field_type":"str","required":false,"placeholder":"","list":false,"show":true,"multiline":true,"value":"","fileTypes":[],"file_path":"","name":"chat_history","display_name":"chat_history","advanced":false,"input_types":["Message","Text"],"dynamic":false,"info":"","load_from_db":false,"title_case":false,"type":"str"},"context":{"field_type":"str","required":false,"placeholder":"","list":false,"show":true,"multiline":true,"value":"","fileTypes":[],"file_path":"","name":"context","display_name":"context","advanced":false,"input_types":["Message","Text"],"dynamic":false,"info":"","load_from_db":false,"title_case":false,"type":"str"},"question":{"field_type":"str","required":false,"placeholder":"","list":false,"show":true,"multiline":true,"value":"","fileTypes":[],"file_path":"","name":"question","display_name":"question","advanced":false,"input_types":["Message","Text"],"dynamic":false,"info":"","load_from_db":false,"title_case":false,"type":"str"}},"description":"Create a prompt template with dynamic variables.","icon":"prompts","base_classes":["Message"],"display_name":"Prompt","documentation":"","custom_fields":{"template":["chat_history","context","question"]},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"prompt","display_name":"Prompt Message","method":"build_prompt","value":"__UNDEFINED__","cache":true}],"field_order":["template"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"type":"Prompt"},"dragging":false,"height":517,"id":"Prompt-pe8Ic","position":{"x":2184.7321445956895,"y":508.8465154236154},"positionAbsolute":{"x":2184.7321445956895,"y":508.8465154236154},"selected":false,"type":"genericNode","width":320},{"data":{"description":"Display a chat message in the Playground.","display_name":"Chat Output","id":"ChatOutput-Jcmxm","node":{"template":{"_type":"Component","background_color":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"background_color","value":"","display_name":"Background Color","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The background color of the icon.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"chat_icon":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"chat_icon","value":"","display_name":"Icon","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The icon of the message.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.base.io.chat import ChatComponent\nfrom langflow.inputs import BoolInput\nfrom langflow.io import DropdownInput, MessageInput, MessageTextInput, Output\nfrom langflow.schema.message import Message\nfrom langflow.schema.properties import Source\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI, MESSAGE_SENDER_USER\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n icon = \"MessagesSquare\"\n name = \"ChatOutput\"\n\n inputs = [\n MessageInput(\n name=\"input_value\",\n display_name=\"Text\",\n info=\"Message to be passed as output.\",\n ),\n BoolInput(\n name=\"should_store_message\",\n display_name=\"Store Messages\",\n info=\"Store the message in the history.\",\n value=True,\n advanced=True,\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[MESSAGE_SENDER_AI, MESSAGE_SENDER_USER],\n value=MESSAGE_SENDER_AI,\n advanced=True,\n info=\"Type of sender.\",\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Name of the sender.\",\n value=MESSAGE_SENDER_NAME_AI,\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"data_template\",\n display_name=\"Data Template\",\n value=\"{text}\",\n advanced=True,\n info=\"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.\",\n ),\n MessageTextInput(\n name=\"background_color\",\n display_name=\"Background Color\",\n info=\"The background color of the icon.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"chat_icon\",\n display_name=\"Icon\",\n info=\"The icon of the message.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"text_color\",\n display_name=\"Text Color\",\n info=\"The text color of the name\",\n advanced=True,\n ),\n ]\n outputs = [\n Output(\n display_name=\"Message\",\n name=\"message\",\n method=\"message_response\",\n ),\n ]\n\n def _build_source(self, _id: str | None, display_name: str | None, source: str | None) -> Source:\n source_dict = {}\n if _id:\n source_dict[\"id\"] = _id\n if display_name:\n source_dict[\"display_name\"] = display_name\n if source:\n source_dict[\"source\"] = source\n return Source(**source_dict)\n\n def message_response(self) -> Message:\n _source, _icon, _display_name, _source_id = self.get_properties_from_source_component()\n _background_color = self.background_color\n _text_color = self.text_color\n if self.chat_icon:\n _icon = self.chat_icon\n message = self.input_value if isinstance(self.input_value, Message) else Message(text=self.input_value)\n message.sender = self.sender\n message.sender_name = self.sender_name\n message.session_id = self.session_id\n message.flow_id = self.graph.flow_id if hasattr(self, \"graph\") else None\n message.properties.source = self._build_source(_source_id, _display_name, _source)\n message.properties.icon = _icon\n message.properties.background_color = _background_color\n message.properties.text_color = _text_color\n if self.session_id and isinstance(message, Message) and self.should_store_message:\n stored_message = self.send_message(\n message,\n )\n self.message.value = stored_message\n message = stored_message\n\n self.status = message\n return message\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"data_template":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"data_template","value":"{text}","display_name":"Data Template","advanced":true,"input_types":["Message"],"dynamic":false,"info":"Template to convert Data to Text. If left empty, it will be dynamically set to the Data's text key.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"input_value":{"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"input_value","value":"","display_name":"Text","advanced":false,"input_types":["Message"],"dynamic":false,"info":"Message to be passed as output.","title_case":false,"type":"str","_input_type":"MessageInput"},"sender":{"tool_mode":false,"trace_as_metadata":true,"options":["Machine","User"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"sender","value":"Machine","display_name":"Sender Type","advanced":true,"dynamic":false,"info":"Type of sender.","title_case":false,"type":"str","_input_type":"DropdownInput"},"sender_name":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender_name","value":"AI","display_name":"Sender Name","advanced":true,"input_types":["Message"],"dynamic":false,"info":"Name of the sender.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"session_id":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"should_store_message":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"should_store_message","value":true,"display_name":"Store Messages","advanced":true,"dynamic":false,"info":"Store the message in the history.","title_case":false,"type":"bool","_input_type":"BoolInput"},"text_color":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"text_color","value":"","display_name":"Text Color","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The text color of the name","title_case":false,"type":"str","_input_type":"MessageTextInput"}},"description":"Display a chat message in the Playground.","icon":"MessagesSquare","base_classes":["Message"],"display_name":"Chat Output","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"message","display_name":"Message","method":"message_response","value":"__UNDEFINED__","cache":true}],"field_order":["input_value","should_store_message","sender","sender_name","session_id","data_template","background_color","chat_icon","text_color"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"type":"ChatOutput"},"dragging":false,"height":319,"id":"ChatOutput-Jcmxm","position":{"x":3226.685725006823,"y":741.6553131901255},"positionAbsolute":{"x":3226.685725006823,"y":741.6553131901255},"selected":false,"type":"genericNode","width":320},{"id":"AstraDB-m7obA","type":"genericNode","position":{"x":1211.0525020202301,"y":138.73813939746373},"data":{"type":"AstraDB","node":{"template":{"_type":"Component","ingest_data":{"tool_mode":false,"trace_as_metadata":true,"list":true,"trace_as_input":true,"required":false,"placeholder":"","show":true,"name":"ingest_data","value":"","display_name":"Ingest Data","advanced":false,"input_types":["Data"],"dynamic":false,"info":"","title_case":false,"type":"other","_input_type":"DataInput"},"api_endpoint":{"load_from_db":false,"required":true,"placeholder":"","show":true,"name":"api_endpoint","value":"","display_name":"API Endpoint","advanced":false,"input_types":["Message"],"dynamic":false,"info":"API endpoint URL for the Astra DB service.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"},"batch_size":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"batch_size","value":"","display_name":"Batch Size","advanced":true,"dynamic":false,"info":"Optional number of data to process in a single batch.","title_case":false,"type":"int","_input_type":"IntInput"},"bulk_delete_concurrency":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"bulk_delete_concurrency","value":"","display_name":"Bulk Delete Concurrency","advanced":true,"dynamic":false,"info":"Optional concurrency level for bulk delete operations.","title_case":false,"type":"int","_input_type":"IntInput"},"bulk_insert_batch_concurrency":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"bulk_insert_batch_concurrency","value":"","display_name":"Bulk Insert Batch Concurrency","advanced":true,"dynamic":false,"info":"Optional concurrency level for bulk insert operations.","title_case":false,"type":"int","_input_type":"IntInput"},"bulk_insert_overwrite_concurrency":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"bulk_insert_overwrite_concurrency","value":"","display_name":"Bulk Insert Overwrite Concurrency","advanced":true,"dynamic":false,"info":"Optional concurrency level for bulk insert operations that overwrite existing data.","title_case":false,"type":"int","_input_type":"IntInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"import os\n\nimport orjson\nfrom astrapy.admin import parse_api_endpoint\n\nfrom langflow.base.vectorstores.model import LCVectorStoreComponent, check_cached_vector_store\nfrom langflow.helpers import docs_to_data\nfrom langflow.inputs import DictInput, FloatInput, MessageTextInput\nfrom langflow.io import (\n BoolInput,\n DataInput,\n DropdownInput,\n HandleInput,\n IntInput,\n MultilineInput,\n SecretStrInput,\n StrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AstraVectorStoreComponent(LCVectorStoreComponent):\n display_name: str = \"Astra DB\"\n description: str = \"Implementation of Vector Store using Astra DB with search capabilities\"\n documentation: str = \"https://docs.langflow.org/starter-projects-vector-store-rag\"\n name = \"AstraDB\"\n icon: str = \"AstraDB\"\n\n VECTORIZE_PROVIDERS_MAPPING = {\n \"Azure OpenAI\": [\"azureOpenAI\", [\"text-embedding-3-small\", \"text-embedding-3-large\", \"text-embedding-ada-002\"]],\n \"Hugging Face - Dedicated\": [\"huggingfaceDedicated\", [\"endpoint-defined-model\"]],\n \"Hugging Face - Serverless\": [\n \"huggingface\",\n [\n \"sentence-transformers/all-MiniLM-L6-v2\",\n \"intfloat/multilingual-e5-large\",\n \"intfloat/multilingual-e5-large-instruct\",\n \"BAAI/bge-small-en-v1.5\",\n \"BAAI/bge-base-en-v1.5\",\n \"BAAI/bge-large-en-v1.5\",\n ],\n ],\n \"Jina AI\": [\n \"jinaAI\",\n [\n \"jina-embeddings-v2-base-en\",\n \"jina-embeddings-v2-base-de\",\n \"jina-embeddings-v2-base-es\",\n \"jina-embeddings-v2-base-code\",\n \"jina-embeddings-v2-base-zh\",\n ],\n ],\n \"Mistral AI\": [\"mistral\", [\"mistral-embed\"]],\n \"NVIDIA\": [\"nvidia\", [\"NV-Embed-QA\"]],\n \"OpenAI\": [\"openai\", [\"text-embedding-3-small\", \"text-embedding-3-large\", \"text-embedding-ada-002\"]],\n \"Upstage\": [\"upstageAI\", [\"solar-embedding-1-large\"]],\n \"Voyage AI\": [\n \"voyageAI\",\n [\"voyage-large-2-instruct\", \"voyage-law-2\", \"voyage-code-2\", \"voyage-large-2\", \"voyage-2\"],\n ],\n }\n\n inputs = [\n SecretStrInput(\n name=\"token\",\n display_name=\"Astra DB Application Token\",\n info=\"Authentication token for accessing Astra DB.\",\n value=\"ASTRA_DB_APPLICATION_TOKEN\",\n required=True,\n advanced=os.getenv(\"ASTRA_ENHANCED\", \"false\").lower() == \"true\",\n ),\n SecretStrInput(\n name=\"api_endpoint\",\n display_name=\"Database\" if os.getenv(\"ASTRA_ENHANCED\", \"false\").lower() == \"true\" else \"API Endpoint\",\n info=\"API endpoint URL for the Astra DB service.\",\n value=\"ASTRA_DB_API_ENDPOINT\",\n required=True,\n ),\n StrInput(\n name=\"collection_name\",\n display_name=\"Collection Name\",\n info=\"The name of the collection within Astra DB where the vectors will be stored.\",\n required=True,\n ),\n MultilineInput(\n name=\"search_input\",\n display_name=\"Search Input\",\n ),\n DataInput(\n name=\"ingest_data\",\n display_name=\"Ingest Data\",\n is_list=True,\n ),\n StrInput(\n name=\"namespace\",\n display_name=\"Namespace\",\n info=\"Optional namespace within Astra DB to use for the collection.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"embedding_choice\",\n display_name=\"Embedding Model or Astra Vectorize\",\n info=\"Determines whether to use Astra Vectorize for the collection.\",\n options=[\"Embedding Model\", \"Astra Vectorize\"],\n real_time_refresh=True,\n value=\"Embedding Model\",\n ),\n HandleInput(\n name=\"embedding\",\n display_name=\"Embedding Model\",\n input_types=[\"Embeddings\"],\n info=\"Allows an embedding model configuration.\",\n ),\n DropdownInput(\n name=\"metric\",\n display_name=\"Metric\",\n info=\"Optional distance metric for vector comparisons in the vector store.\",\n options=[\"cosine\", \"dot_product\", \"euclidean\"],\n value=\"cosine\",\n advanced=True,\n ),\n IntInput(\n name=\"batch_size\",\n display_name=\"Batch Size\",\n info=\"Optional number of data to process in a single batch.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_insert_batch_concurrency\",\n display_name=\"Bulk Insert Batch Concurrency\",\n info=\"Optional concurrency level for bulk insert operations.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_insert_overwrite_concurrency\",\n display_name=\"Bulk Insert Overwrite Concurrency\",\n info=\"Optional concurrency level for bulk insert operations that overwrite existing data.\",\n advanced=True,\n ),\n IntInput(\n name=\"bulk_delete_concurrency\",\n display_name=\"Bulk Delete Concurrency\",\n info=\"Optional concurrency level for bulk delete operations.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"setup_mode\",\n display_name=\"Setup Mode\",\n info=\"Configuration mode for setting up the vector store, with options like 'Sync' or 'Off'.\",\n options=[\"Sync\", \"Off\"],\n advanced=True,\n value=\"Sync\",\n ),\n BoolInput(\n name=\"pre_delete_collection\",\n display_name=\"Pre Delete Collection\",\n info=\"Boolean flag to determine whether to delete the collection before creating a new one.\",\n advanced=True,\n ),\n StrInput(\n name=\"metadata_indexing_include\",\n display_name=\"Metadata Indexing Include\",\n info=\"Optional list of metadata fields to include in the indexing.\",\n is_list=True,\n advanced=True,\n ),\n StrInput(\n name=\"metadata_indexing_exclude\",\n display_name=\"Metadata Indexing Exclude\",\n info=\"Optional list of metadata fields to exclude from the indexing.\",\n is_list=True,\n advanced=True,\n ),\n StrInput(\n name=\"collection_indexing_policy\",\n display_name=\"Collection Indexing Policy\",\n info='Optional JSON string for the \"indexing\" field of the collection. '\n \"See https://docs.datastax.com/en/astra-db-serverless/api-reference/collections.html#the-indexing-option\",\n advanced=True,\n ),\n IntInput(\n name=\"number_of_results\",\n display_name=\"Number of Results\",\n info=\"Number of results to return.\",\n advanced=True,\n value=4,\n ),\n DropdownInput(\n name=\"search_type\",\n display_name=\"Search Type\",\n info=\"Search type to use\",\n options=[\"Similarity\", \"Similarity with score threshold\", \"MMR (Max Marginal Relevance)\"],\n value=\"Similarity\",\n advanced=True,\n ),\n FloatInput(\n name=\"search_score_threshold\",\n display_name=\"Search Score Threshold\",\n info=\"Minimum similarity score threshold for search results. \"\n \"(when using 'Similarity with score threshold')\",\n value=0,\n advanced=True,\n ),\n DictInput(\n name=\"search_filter\",\n display_name=\"Search Metadata Filter\",\n info=\"Optional dictionary of filters to apply to the search query.\",\n advanced=True,\n is_list=True,\n ),\n ]\n\n def del_fields(self, build_config, field_list):\n for field in field_list:\n if field in build_config:\n del build_config[field]\n\n return build_config\n\n def insert_in_dict(self, build_config, field_name, new_parameters):\n # Insert the new key-value pair after the found key\n for new_field_name, new_parameter in new_parameters.items():\n # Get all the items as a list of tuples (key, value)\n items = list(build_config.items())\n\n # Find the index of the key to insert after\n idx = len(items)\n for i, (key, _) in enumerate(items):\n if key == field_name:\n idx = i + 1\n break\n\n items.insert(idx, (new_field_name, new_parameter))\n\n # Clear the original dictionary and update with the modified items\n build_config.clear()\n build_config.update(items)\n\n return build_config\n\n def update_build_config(self, build_config: dict, field_value: str, field_name: str | None = None):\n if field_name == \"embedding_choice\":\n if field_value == \"Astra Vectorize\":\n self.del_fields(build_config, [\"embedding\"])\n\n new_parameter = DropdownInput(\n name=\"embedding_provider\",\n display_name=\"Embedding Provider\",\n options=self.VECTORIZE_PROVIDERS_MAPPING.keys(),\n value=\"\",\n required=True,\n real_time_refresh=True,\n ).to_dict()\n\n self.insert_in_dict(build_config, \"embedding_choice\", {\"embedding_provider\": new_parameter})\n else:\n self.del_fields(\n build_config,\n [\n \"embedding_provider\",\n \"model\",\n \"z_01_model_parameters\",\n \"z_02_api_key_name\",\n \"z_03_provider_api_key\",\n \"z_04_authentication\",\n ],\n )\n\n new_parameter = HandleInput(\n name=\"embedding\",\n display_name=\"Embedding Model\",\n input_types=[\"Embeddings\"],\n info=\"Allows an embedding model configuration.\",\n ).to_dict()\n\n self.insert_in_dict(build_config, \"embedding_choice\", {\"embedding\": new_parameter})\n\n elif field_name == \"embedding_provider\":\n self.del_fields(\n build_config,\n [\"model\", \"z_01_model_parameters\", \"z_02_api_key_name\", \"z_03_provider_api_key\", \"z_04_authentication\"],\n )\n\n model_options = self.VECTORIZE_PROVIDERS_MAPPING[field_value][1]\n\n new_parameter = DropdownInput(\n name=\"model\",\n display_name=\"Model\",\n info=\"The embedding model to use for the selected provider. Each provider has a different set of \"\n \"models available (full list at \"\n \"https://docs.datastax.com/en/astra-db-serverless/databases/embedding-generation.html):\\n\\n\"\n f\"{', '.join(model_options)}\",\n options=model_options,\n value=None,\n required=True,\n real_time_refresh=True,\n ).to_dict()\n\n self.insert_in_dict(build_config, \"embedding_provider\", {\"model\": new_parameter})\n\n elif field_name == \"model\":\n self.del_fields(\n build_config,\n [\"z_01_model_parameters\", \"z_02_api_key_name\", \"z_03_provider_api_key\", \"z_04_authentication\"],\n )\n\n new_parameter_1 = DictInput(\n name=\"z_01_model_parameters\",\n display_name=\"Model Parameters\",\n is_list=True,\n ).to_dict()\n\n new_parameter_2 = MessageTextInput(\n name=\"z_02_api_key_name\",\n display_name=\"API Key Name\",\n info=\"The name of the embeddings provider API key stored on Astra. \"\n \"If set, it will override the 'ProviderKey' in the authentication parameters.\",\n ).to_dict()\n\n new_parameter_3 = SecretStrInput(\n load_from_db=False,\n name=\"z_03_provider_api_key\",\n display_name=\"Provider API Key\",\n info=\"An alternative to the Astra Authentication that passes an API key for the provider \"\n \"with each request to Astra DB. \"\n \"This may be used when Vectorize is configured for the collection, \"\n \"but no corresponding provider secret is stored within Astra's key management system.\",\n ).to_dict()\n\n new_parameter_4 = DictInput(\n name=\"z_04_authentication\",\n display_name=\"Authentication Parameters\",\n is_list=True,\n ).to_dict()\n\n self.insert_in_dict(\n build_config,\n \"model\",\n {\n \"z_01_model_parameters\": new_parameter_1,\n \"z_02_api_key_name\": new_parameter_2,\n \"z_03_provider_api_key\": new_parameter_3,\n \"z_04_authentication\": new_parameter_4,\n },\n )\n\n return build_config\n\n def build_vectorize_options(self, **kwargs):\n for attribute in [\n \"embedding_provider\",\n \"model\",\n \"z_01_model_parameters\",\n \"z_02_api_key_name\",\n \"z_03_provider_api_key\",\n \"z_04_authentication\",\n ]:\n if not hasattr(self, attribute):\n setattr(self, attribute, None)\n\n # Fetch values from kwargs if any self.* attributes are None\n provider_value = self.VECTORIZE_PROVIDERS_MAPPING.get(self.embedding_provider, [None])[0] or kwargs.get(\n \"embedding_provider\"\n )\n model_name = self.model or kwargs.get(\"model\")\n authentication = {**(self.z_04_authentication or kwargs.get(\"z_04_authentication\", {}))}\n parameters = self.z_01_model_parameters or kwargs.get(\"z_01_model_parameters\", {})\n\n # Set the API key name if provided\n api_key_name = self.z_02_api_key_name or kwargs.get(\"z_02_api_key_name\")\n provider_key = self.z_03_provider_api_key or kwargs.get(\"z_03_provider_api_key\")\n if api_key_name:\n authentication[\"providerKey\"] = api_key_name\n\n # Set authentication and parameters to None if no values are provided\n if not authentication:\n authentication = None\n if not parameters:\n parameters = None\n\n return {\n # must match astrapy.info.CollectionVectorServiceOptions\n \"collection_vector_service_options\": {\n \"provider\": provider_value,\n \"modelName\": model_name,\n \"authentication\": authentication,\n \"parameters\": parameters,\n },\n \"collection_embedding_api_key\": provider_key,\n }\n\n @check_cached_vector_store\n def build_vector_store(self, vectorize_options=None):\n try:\n from langchain_astradb import AstraDBVectorStore\n from langchain_astradb.utils.astradb import SetupMode\n except ImportError as e:\n msg = (\n \"Could not import langchain Astra DB integration package. \"\n \"Please install it with `pip install langchain-astradb`.\"\n )\n raise ImportError(msg) from e\n\n try:\n if not self.setup_mode:\n self.setup_mode = self._inputs[\"setup_mode\"].options[0]\n\n setup_mode_value = SetupMode[self.setup_mode.upper()]\n except KeyError as e:\n msg = f\"Invalid setup mode: {self.setup_mode}\"\n raise ValueError(msg) from e\n\n if self.embedding_choice == \"Embedding Model\":\n embedding_dict = {\"embedding\": self.embedding}\n else:\n from astrapy.info import CollectionVectorServiceOptions\n\n # Fetch values from kwargs if any self.* attributes are None\n dict_options = vectorize_options or self.build_vectorize_options()\n\n # Set the embedding dictionary\n embedding_dict = {\n \"collection_vector_service_options\": CollectionVectorServiceOptions.from_dict(\n dict_options.get(\"collection_vector_service_options\")\n ),\n \"collection_embedding_api_key\": dict_options.get(\"collection_embedding_api_key\"),\n }\n\n try:\n vector_store = AstraDBVectorStore(\n collection_name=self.collection_name,\n token=self.token,\n api_endpoint=self.api_endpoint,\n namespace=self.namespace or None,\n environment=parse_api_endpoint(self.api_endpoint).environment if self.api_endpoint else None,\n metric=self.metric or None,\n batch_size=self.batch_size or None,\n bulk_insert_batch_concurrency=self.bulk_insert_batch_concurrency or None,\n bulk_insert_overwrite_concurrency=self.bulk_insert_overwrite_concurrency or None,\n bulk_delete_concurrency=self.bulk_delete_concurrency or None,\n setup_mode=setup_mode_value,\n pre_delete_collection=self.pre_delete_collection,\n metadata_indexing_include=[s for s in self.metadata_indexing_include if s] or None,\n metadata_indexing_exclude=[s for s in self.metadata_indexing_exclude if s] or None,\n collection_indexing_policy=orjson.dumps(self.collection_indexing_policy)\n if self.collection_indexing_policy\n else None,\n **embedding_dict,\n )\n except Exception as e:\n msg = f\"Error initializing AstraDBVectorStore: {e}\"\n raise ValueError(msg) from e\n\n self._add_documents_to_vector_store(vector_store)\n\n return vector_store\n\n def _add_documents_to_vector_store(self, vector_store) -> None:\n documents = []\n for _input in self.ingest_data or []:\n if isinstance(_input, Data):\n documents.append(_input.to_lc_document())\n else:\n msg = \"Vector Store Inputs must be Data objects.\"\n raise TypeError(msg)\n\n if documents:\n self.log(f\"Adding {len(documents)} documents to the Vector Store.\")\n try:\n vector_store.add_documents(documents)\n except Exception as e:\n msg = f\"Error adding documents to AstraDBVectorStore: {e}\"\n raise ValueError(msg) from e\n else:\n self.log(\"No documents to add to the Vector Store.\")\n\n def _map_search_type(self) -> str:\n if self.search_type == \"Similarity with score threshold\":\n return \"similarity_score_threshold\"\n if self.search_type == \"MMR (Max Marginal Relevance)\":\n return \"mmr\"\n return \"similarity\"\n\n def _build_search_args(self):\n args = {\n \"k\": self.number_of_results,\n \"score_threshold\": self.search_score_threshold,\n }\n\n if self.search_filter:\n clean_filter = {k: v for k, v in self.search_filter.items() if k and v}\n if len(clean_filter) > 0:\n args[\"filter\"] = clean_filter\n return args\n\n def search_documents(self, vector_store=None) -> list[Data]:\n if not vector_store:\n vector_store = self.build_vector_store()\n\n self.log(f\"Search input: {self.search_input}\")\n self.log(f\"Search type: {self.search_type}\")\n self.log(f\"Number of results: {self.number_of_results}\")\n\n if self.search_input and isinstance(self.search_input, str) and self.search_input.strip():\n try:\n search_type = self._map_search_type()\n search_args = self._build_search_args()\n\n docs = vector_store.search(query=self.search_input, search_type=search_type, **search_args)\n except Exception as e:\n msg = f\"Error performing search in AstraDBVectorStore: {e}\"\n raise ValueError(msg) from e\n\n self.log(f\"Retrieved documents: {len(docs)}\")\n\n data = docs_to_data(docs)\n self.log(f\"Converted documents to data: {len(data)}\")\n self.status = data\n return data\n self.log(\"No search input provided. Skipping search.\")\n return []\n\n def get_retriever_kwargs(self):\n search_args = self._build_search_args()\n return {\n \"search_type\": self._map_search_type(),\n \"search_kwargs\": search_args,\n }\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"collection_indexing_policy":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"collection_indexing_policy","value":"","display_name":"Collection Indexing Policy","advanced":true,"dynamic":false,"info":"Optional JSON string for the \"indexing\" field of the collection. See https://docs.datastax.com/en/astra-db-serverless/api-reference/collections.html#the-indexing-option","title_case":false,"type":"str","_input_type":"StrInput"},"collection_name":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":true,"placeholder":"","show":true,"name":"collection_name","value":"user_logs","display_name":"Collection Name","advanced":false,"dynamic":false,"info":"The name of the collection within Astra DB where the vectors will be stored.","title_case":false,"type":"str","_input_type":"StrInput"},"embedding_choice":{"tool_mode":false,"trace_as_metadata":true,"options":["Embedding Model","Astra Vectorize"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"embedding_choice","value":"Astra Vectorize","display_name":"Embedding Model or Astra Vectorize","advanced":false,"dynamic":false,"info":"Determines whether to use Astra Vectorize for the collection.","real_time_refresh":true,"title_case":false,"type":"str","_input_type":"DropdownInput"},"embedding_provider":{"tool_mode":false,"trace_as_metadata":true,"options":["Azure OpenAI","Hugging Face - Dedicated","Hugging Face - Serverless","Jina AI","Mistral AI","NVIDIA","OpenAI","Upstage","Voyage AI"],"combobox":false,"required":true,"placeholder":"","show":true,"name":"embedding_provider","value":"NVIDIA","display_name":"Embedding Provider","advanced":false,"dynamic":false,"info":"","real_time_refresh":true,"title_case":false,"type":"str","_input_type":"DropdownInput"},"model":{"tool_mode":false,"trace_as_metadata":true,"options":["NV-Embed-QA"],"combobox":false,"required":true,"placeholder":"","show":true,"name":"model","display_name":"Model","advanced":false,"dynamic":false,"info":"The embedding model to use for the selected provider. Each provider has a different set of models available (full list at https://docs.datastax.com/en/astra-db-serverless/databases/embedding-generation.html):\n\nNV-Embed-QA","real_time_refresh":true,"title_case":false,"type":"str","_input_type":"DropdownInput","value":"NV-Embed-QA"},"z_04_authentication":{"trace_as_input":true,"list":true,"required":false,"placeholder":"","show":true,"name":"z_04_authentication","value":{},"display_name":"Authentication Parameters","advanced":true,"dynamic":false,"info":"","title_case":false,"type":"dict","_input_type":"DictInput"},"z_03_provider_api_key":{"load_from_db":false,"required":false,"placeholder":"","show":true,"name":"z_03_provider_api_key","value":"","display_name":"Provider API Key","advanced":true,"input_types":["Message"],"dynamic":false,"info":"An alternative to the Astra Authentication that passes an API key for the provider with each request to Astra DB. This may be used when Vectorize is configured for the collection, but no corresponding provider secret is stored within Astra's key management system.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"},"z_02_api_key_name":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"z_02_api_key_name","value":"","display_name":"API Key Name","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The name of the embeddings provider API key stored on Astra. If set, it will override the 'ProviderKey' in the authentication parameters.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"z_01_model_parameters":{"trace_as_input":true,"list":true,"required":false,"placeholder":"","show":true,"name":"z_01_model_parameters","value":{},"display_name":"Model Parameters","advanced":true,"dynamic":false,"info":"","title_case":false,"type":"dict","_input_type":"DictInput"},"metadata_indexing_exclude":{"trace_as_metadata":true,"load_from_db":false,"list":true,"required":false,"placeholder":"","show":true,"name":"metadata_indexing_exclude","value":"","display_name":"Metadata Indexing Exclude","advanced":true,"dynamic":false,"info":"Optional list of metadata fields to exclude from the indexing.","title_case":false,"type":"str","_input_type":"StrInput"},"metadata_indexing_include":{"trace_as_metadata":true,"load_from_db":false,"list":true,"required":false,"placeholder":"","show":true,"name":"metadata_indexing_include","value":"","display_name":"Metadata Indexing Include","advanced":true,"dynamic":false,"info":"Optional list of metadata fields to include in the indexing.","title_case":false,"type":"str","_input_type":"StrInput"},"metric":{"tool_mode":false,"trace_as_metadata":true,"options":["cosine","dot_product","euclidean"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"metric","value":"","display_name":"Metric","advanced":true,"dynamic":false,"info":"Optional distance metric for vector comparisons in the vector store.","title_case":false,"type":"str","_input_type":"DropdownInput","load_from_db":false},"namespace":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"namespace","value":"","display_name":"Namespace","advanced":true,"dynamic":false,"info":"Optional namespace within Astra DB to use for the collection.","title_case":false,"type":"str","_input_type":"StrInput"},"number_of_results":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"number_of_results","value":10,"display_name":"Number of Results","advanced":false,"dynamic":false,"info":"Number of results to return.","title_case":false,"type":"int","_input_type":"IntInput","load_from_db":false},"pre_delete_collection":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"pre_delete_collection","value":false,"display_name":"Pre Delete Collection","advanced":true,"dynamic":false,"info":"Boolean flag to determine whether to delete the collection before creating a new one.","title_case":false,"type":"bool","_input_type":"BoolInput"},"search_filter":{"trace_as_input":true,"list":true,"required":false,"placeholder":"","show":true,"name":"search_filter","value":{},"display_name":"Search Metadata Filter","advanced":true,"dynamic":false,"info":"Optional dictionary of filters to apply to the search query.","title_case":false,"type":"dict","_input_type":"DictInput"},"search_input":{"tool_mode":false,"trace_as_input":true,"multiline":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"search_input","value":"","display_name":"Search Input","advanced":false,"input_types":["Message"],"dynamic":false,"info":"","title_case":false,"type":"str","_input_type":"MultilineInput"},"search_score_threshold":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"search_score_threshold","value":0,"display_name":"Search Score Threshold","advanced":true,"dynamic":false,"info":"Minimum similarity score threshold for search results. (when using 'Similarity with score threshold')","title_case":false,"type":"float","_input_type":"FloatInput"},"search_type":{"tool_mode":false,"trace_as_metadata":true,"options":["Similarity","Similarity with score threshold","MMR (Max Marginal Relevance)"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"search_type","value":"Similarity","display_name":"Search Type","advanced":true,"dynamic":false,"info":"Search type to use","title_case":false,"type":"str","_input_type":"DropdownInput"},"setup_mode":{"tool_mode":false,"trace_as_metadata":true,"options":["Sync","Off"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"setup_mode","value":"Sync","display_name":"Setup Mode","advanced":true,"dynamic":false,"info":"Configuration mode for setting up the vector store, with options like 'Sync' or 'Off'.","title_case":false,"type":"str","_input_type":"DropdownInput"},"token":{"load_from_db":false,"required":true,"placeholder":"","show":true,"name":"token","value":"","display_name":"Astra DB Application Token","advanced":false,"input_types":["Message"],"dynamic":false,"info":"Authentication token for accessing Astra DB.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"}},"description":"Implementation of Vector Store using Astra DB with search capabilities","icon":"AstraDB","base_classes":["Data","Retriever"],"display_name":"Astra DB","documentation":"https://docs.langflow.org/starter-projects-vector-store-rag","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Retriever"],"selected":"Retriever","name":"base_retriever","hidden":true,"display_name":"Retriever","method":"build_base_retriever","value":"__UNDEFINED__","cache":true,"required_inputs":[]},{"types":["Data"],"selected":"Data","name":"search_results","hidden":null,"display_name":"Search Results","method":"search_documents","value":"__UNDEFINED__","cache":true,"required_inputs":["api_endpoint","collection_name","token"]}],"field_order":["token","api_endpoint","collection_name","search_input","ingest_data","namespace","embedding_choice","embedding","metric","batch_size","bulk_insert_batch_concurrency","bulk_insert_overwrite_concurrency","bulk_delete_concurrency","setup_mode","pre_delete_collection","metadata_indexing_include","metadata_indexing_exclude","collection_indexing_policy","number_of_results","search_type","search_score_threshold","search_filter"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"id":"AstraDB-m7obA","description":"Implementation of Vector Store using Astra DB with search capabilities","display_name":"Astra DB"},"selected":false,"width":320,"height":903,"positionAbsolute":{"x":1211.0525020202301,"y":138.73813939746373},"dragging":false},{"id":"AstraDBChatMemory-9Hqar","type":"genericNode","position":{"x":817.7759852078386,"y":-1473.3113706379763},"data":{"type":"AstraDBChatMemory","node":{"template":{"_type":"Component","api_endpoint":{"load_from_db":false,"required":true,"placeholder":"","show":true,"name":"api_endpoint","value":"","display_name":"API Endpoint","advanced":false,"input_types":["Message"],"dynamic":false,"info":"API endpoint URL for the Astra DB service.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"import os\n\nfrom astrapy.admin import parse_api_endpoint\n\nfrom langflow.base.memory.model import LCChatMemoryComponent\nfrom langflow.field_typing import BaseChatMessageHistory\nfrom langflow.inputs import MessageTextInput, SecretStrInput, StrInput\n\n\nclass AstraDBChatMemory(LCChatMemoryComponent):\n display_name = \"Astra DB Chat Memory\"\n description = \"Retrieves and store chat messages from Astra DB.\"\n name = \"AstraDBChatMemory\"\n icon: str = \"AstraDB\"\n\n inputs = [\n SecretStrInput(\n name=\"token\",\n display_name=\"Astra DB Application Token\",\n info=\"Authentication token for accessing Astra DB.\",\n value=\"ASTRA_DB_APPLICATION_TOKEN\",\n required=True,\n advanced=os.getenv(\"ASTRA_ENHANCED\", \"false\").lower() == \"true\",\n ),\n SecretStrInput(\n name=\"api_endpoint\",\n display_name=\"API Endpoint\",\n info=\"API endpoint URL for the Astra DB service.\",\n value=\"ASTRA_DB_API_ENDPOINT\",\n required=True,\n ),\n StrInput(\n name=\"collection_name\",\n display_name=\"Collection Name\",\n info=\"The name of the collection within Astra DB where the vectors will be stored.\",\n required=True,\n ),\n StrInput(\n name=\"namespace\",\n display_name=\"Namespace\",\n info=\"Optional namespace within Astra DB to use for the collection.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n advanced=True,\n ),\n ]\n\n def build_message_history(self) -> BaseChatMessageHistory:\n try:\n from langchain_astradb.chat_message_histories import AstraDBChatMessageHistory\n except ImportError as e:\n msg = (\n \"Could not import langchain Astra DB integration package. \"\n \"Please install it with `pip install langchain-astradb`.\"\n )\n raise ImportError(msg) from e\n\n return AstraDBChatMessageHistory(\n session_id=self.session_id,\n collection_name=self.collection_name,\n token=self.token,\n api_endpoint=self.api_endpoint,\n namespace=self.namespace or None,\n environment=parse_api_endpoint(self.api_endpoint).environment,\n )\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"collection_name":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":true,"placeholder":"","show":true,"name":"collection_name","value":"chat_history","display_name":"Collection Name","advanced":false,"dynamic":false,"info":"The name of the collection within Astra DB where the vectors will be stored.","title_case":false,"type":"str","_input_type":"StrInput"},"namespace":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"namespace","value":"","display_name":"Namespace","advanced":true,"dynamic":false,"info":"Optional namespace within Astra DB to use for the collection.","title_case":false,"type":"str","_input_type":"StrInput"},"session_id":{"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"token":{"load_from_db":false,"required":true,"placeholder":"","show":true,"name":"token","value":"","display_name":"Astra DB Application Token","advanced":false,"input_types":["Message"],"dynamic":false,"info":"Authentication token for accessing Astra DB.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"}},"description":"Retrieves and store chat messages from Astra DB.","icon":"AstraDB","base_classes":["BaseChatMessageHistory"],"display_name":"Astra DB Chat Memory","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["BaseChatMessageHistory"],"selected":"BaseChatMessageHistory","name":"memory","display_name":"Memory","method":"build_message_history","value":"__UNDEFINED__","cache":true,"required_inputs":["api_endpoint","collection_name","namespace","session_id","token"]}],"field_order":["token","api_endpoint","collection_name","namespace","session_id"],"beta":false,"edited":false,"metadata":{},"lf_version":"1.1.0"},"id":"AstraDBChatMemory-9Hqar","description":"Retrieves and store chat messages from Astra DB.","display_name":"Astra DB Chat Memory"},"selected":false,"width":320,"height":511,"positionAbsolute":{"x":817.7759852078386,"y":-1473.3113706379763},"dragging":false},{"id":"Memory-4WDcV","type":"genericNode","position":{"x":1498.5139357929736,"y":-624.2722516198505},"data":{"type":"Memory","node":{"template":{"_type":"Component","memory":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"memory","value":"","display_name":"External Memory","advanced":false,"input_types":["BaseChatMessageHistory"],"dynamic":false,"info":"Retrieve messages from an external memory. If empty, it will use the Langflow tables.","title_case":false,"type":"other","_input_type":"HandleInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langchain.memory import ConversationBufferMemory\n\nfrom langflow.custom import Component\nfrom langflow.field_typing import BaseChatMemory\nfrom langflow.helpers.data import data_to_text\nfrom langflow.inputs import HandleInput\nfrom langflow.io import DropdownInput, IntInput, MessageTextInput, MultilineInput, Output\nfrom langflow.memory import LCBuiltinChatMemory, get_messages\nfrom langflow.schema import Data\nfrom langflow.schema.message import Message\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_USER\n\n\nclass MemoryComponent(Component):\n display_name = \"Message History\"\n description = \"Retrieves stored chat messages from Langflow tables or an external memory.\"\n icon = \"message-square-more\"\n name = \"Memory\"\n\n inputs = [\n HandleInput(\n name=\"memory\",\n display_name=\"External Memory\",\n input_types=[\"BaseChatMessageHistory\"],\n info=\"Retrieve messages from an external memory. If empty, it will use the Langflow tables.\",\n ),\n DropdownInput(\n name=\"sender\",\n display_name=\"Sender Type\",\n options=[MESSAGE_SENDER_AI, MESSAGE_SENDER_USER, \"Machine and User\"],\n value=\"Machine and User\",\n info=\"Filter by sender type.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"Filter by sender name.\",\n advanced=True,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Messages\",\n value=100,\n info=\"Number of messages to retrieve.\",\n advanced=True,\n ),\n MessageTextInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n advanced=True,\n ),\n DropdownInput(\n name=\"order\",\n display_name=\"Order\",\n options=[\"Ascending\", \"Descending\"],\n value=\"Ascending\",\n info=\"Order of the messages.\",\n advanced=True,\n ),\n MultilineInput(\n name=\"template\",\n display_name=\"Template\",\n info=\"The template to use for formatting the data. \"\n \"It can contain the keys {text}, {sender} or any other key in the message data.\",\n value=\"{sender_name}: {text}\",\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"messages\", method=\"retrieve_messages\"),\n Output(display_name=\"Text\", name=\"messages_text\", method=\"retrieve_messages_as_text\"),\n ]\n\n def retrieve_messages(self) -> Data:\n sender = self.sender\n sender_name = self.sender_name\n session_id = self.session_id\n n_messages = self.n_messages\n order = \"DESC\" if self.order == \"Descending\" else \"ASC\"\n\n if sender == \"Machine and User\":\n sender = None\n\n if self.memory:\n # override session_id\n self.memory.session_id = session_id\n\n stored = self.memory.messages\n # langchain memories are supposed to return messages in ascending order\n if order == \"DESC\":\n stored = stored[::-1]\n if n_messages:\n stored = stored[:n_messages]\n stored = [Message.from_lc_message(m) for m in stored]\n if sender:\n expected_type = MESSAGE_SENDER_AI if sender == MESSAGE_SENDER_AI else MESSAGE_SENDER_USER\n stored = [m for m in stored if m.type == expected_type]\n else:\n stored = get_messages(\n sender=sender,\n sender_name=sender_name,\n session_id=session_id,\n limit=n_messages,\n order=order,\n )\n self.status = stored\n return stored\n\n def retrieve_messages_as_text(self) -> Message:\n stored_text = data_to_text(self.template, self.retrieve_messages())\n self.status = stored_text\n return Message(text=stored_text)\n\n def build_lc_memory(self) -> BaseChatMemory:\n chat_memory = self.memory or LCBuiltinChatMemory(flow_id=self.flow_id, session_id=self.session_id)\n return ConversationBufferMemory(chat_memory=chat_memory)\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"n_messages":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"n_messages","value":10,"display_name":"Number of Messages","advanced":false,"dynamic":false,"info":"Number of messages to retrieve.","title_case":false,"type":"int","_input_type":"IntInput","load_from_db":false},"order":{"tool_mode":false,"trace_as_metadata":true,"options":["Ascending","Descending"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"order","value":"Ascending","display_name":"Order","advanced":true,"dynamic":false,"info":"Order of the messages.","title_case":false,"type":"str","_input_type":"DropdownInput"},"sender":{"tool_mode":false,"trace_as_metadata":true,"options":["Machine","User","Machine and User"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"sender","value":"Machine and User","display_name":"Sender Type","advanced":true,"dynamic":false,"info":"Filter by sender type.","title_case":false,"type":"str","_input_type":"DropdownInput"},"sender_name":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender_name","value":"","display_name":"Sender Name","advanced":true,"input_types":["Message"],"dynamic":false,"info":"Filter by sender name.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"session_id":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"template":{"tool_mode":false,"trace_as_input":true,"multiline":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"template","value":"{sender_name}: {text}","display_name":"Template","advanced":true,"input_types":["Message"],"dynamic":false,"info":"The template to use for formatting the data. It can contain the keys {text}, {sender} or any other key in the message data.","title_case":false,"type":"str","_input_type":"MultilineInput"}},"description":"Retrieves stored chat messages from Langflow tables or an external memory.","icon":"message-square-more","base_classes":["Data","Message"],"display_name":"Chat Memory","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Data"],"selected":"Data","name":"messages","display_name":"Data","method":"retrieve_messages","value":"__UNDEFINED__","cache":true},{"types":["Message"],"selected":"Message","name":"messages_text","display_name":"Text","method":"retrieve_messages_as_text","value":"__UNDEFINED__","cache":true}],"field_order":["memory","sender","sender_name","n_messages","session_id","order","template"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"id":"Memory-4WDcV","description":"Retrieves stored chat messages from Langflow tables or an external memory.","display_name":"Chat Memory"},"selected":false,"width":320,"height":435,"positionAbsolute":{"x":1498.5139357929736,"y":-624.2722516198505},"dragging":false},{"id":"StoreMessage-udpOG","type":"genericNode","position":{"x":1487.5277788736346,"y":-1703.59289395987},"data":{"type":"StoreMessage","node":{"template":{"_type":"Component","memory":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"memory","value":"","display_name":"External Memory","advanced":false,"input_types":["BaseChatMessageHistory"],"dynamic":false,"info":"The external memory to store the message. If empty, it will use the Langflow tables.","title_case":false,"type":"other","_input_type":"HandleInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.custom import Component\nfrom langflow.inputs import MessageInput, StrInput, HandleInput\nfrom langflow.schema.message import Message\nfrom langflow.template import Output\nfrom langflow.memory import get_messages, store_message\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI\n\n\nclass StoreMessageComponent(Component):\n display_name = \"Store Message\"\n description = \"Stores a chat message or text into Langflow tables or an external memory.\"\n icon = \"save\"\n name = \"StoreMessage\"\n\n inputs = [\n MessageInput(name=\"message\", display_name=\"Message\", info=\"The chat message to be stored.\", required=True),\n HandleInput(\n name=\"memory\",\n display_name=\"External Memory\",\n input_types=[\"BaseChatMessageHistory\"],\n info=\"The external memory to store the message. If empty, it will use the Langflow tables.\",\n ),\n StrInput(\n name=\"sender\",\n display_name=\"Sender\",\n info=\"The sender of the message. Might be Machine or User. If empty, the current sender parameter will be used.\",\n advanced=True,\n ),\n StrInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"The name of the sender. Might be AI or User. If empty, the current sender parameter will be used.\",\n advanced=True,\n ),\n StrInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n value=\"\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Stored Messages\", name=\"stored_messages\", method=\"store_message\"),\n ]\n\n def store_message(self) -> Message:\n message = self.message\n\n message.session_id = self.session_id or message.session_id\n message.sender = self.sender or message.sender or MESSAGE_SENDER_AI\n message.sender_name = self.sender_name or message.sender_name or MESSAGE_SENDER_NAME_AI\n\n if self.memory:\n # override session_id\n self.memory.session_id = message.session_id\n lc_message = message.to_lc_message()\n self.memory.add_messages([lc_message])\n stored = self.memory.messages\n stored = [Message.from_lc_message(m) for m in stored]\n if message.sender:\n stored = [m for m in stored if m.sender == message.sender]\n else:\n store_message(message, flow_id=self.graph.flow_id)\n stored = get_messages(session_id=message.session_id, sender_name=message.sender_name, sender=message.sender)\n self.status = stored\n return stored\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"message":{"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":true,"placeholder":"","show":true,"name":"message","value":"","display_name":"Message","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The chat message to be stored.","title_case":false,"type":"str","_input_type":"MessageInput"},"sender":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender","value":"","display_name":"Sender","advanced":true,"dynamic":false,"info":"The sender of the message. Might be Machine or User. If empty, the current sender parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"},"sender_name":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender_name","value":"","display_name":"Sender Name","advanced":true,"dynamic":false,"info":"The name of the sender. Might be AI or User. If empty, the current sender parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"},"session_id":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"}},"description":"Stores a chat message or text into Langflow tables or an external memory.","icon":"save","base_classes":["Message"],"display_name":"Store Message","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"stored_messages","display_name":"Stored Messages","method":"store_message","value":"__UNDEFINED__","cache":true}],"field_order":["message","memory","sender","sender_name","session_id"],"beta":false,"edited":true,"metadata":{},"lf_version":"1.1.0"},"id":"StoreMessage-udpOG"},"selected":false,"width":320,"height":387,"positionAbsolute":{"x":1487.5277788736346,"y":-1703.59289395987},"dragging":false},{"id":"StoreMessage-cQhUA","type":"genericNode","position":{"x":1486.239111832812,"y":-1223.5079325275838},"data":{"type":"StoreMessage","node":{"template":{"_type":"Component","memory":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"memory","value":"","display_name":"External Memory","advanced":false,"input_types":["BaseChatMessageHistory"],"dynamic":false,"info":"The external memory to store the message. If empty, it will use the Langflow tables.","title_case":false,"type":"other","_input_type":"HandleInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"from langflow.custom import Component\nfrom langflow.inputs import MessageInput, StrInput, HandleInput\nfrom langflow.schema.message import Message\nfrom langflow.template import Output\nfrom langflow.memory import get_messages, store_message\nfrom langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI\n\n\nclass StoreMessageComponent(Component):\n display_name = \"Store Message\"\n description = \"Stores a chat message or text into Langflow tables or an external memory.\"\n icon = \"save\"\n name = \"StoreMessage\"\n\n inputs = [\n MessageInput(name=\"message\", display_name=\"Message\", info=\"The chat message to be stored.\", required=True),\n HandleInput(\n name=\"memory\",\n display_name=\"External Memory\",\n input_types=[\"BaseChatMessageHistory\"],\n info=\"The external memory to store the message. If empty, it will use the Langflow tables.\",\n ),\n StrInput(\n name=\"sender\",\n display_name=\"Sender\",\n info=\"The sender of the message. Might be Machine or User. If empty, the current sender parameter will be used.\",\n advanced=True,\n ),\n StrInput(\n name=\"sender_name\",\n display_name=\"Sender Name\",\n info=\"The name of the sender. Might be AI or User. If empty, the current sender parameter will be used.\",\n advanced=True,\n ),\n StrInput(\n name=\"session_id\",\n display_name=\"Session ID\",\n info=\"The session ID of the chat. If empty, the current session ID parameter will be used.\",\n value=\"\",\n ),\n ]\n\n outputs = [\n Output(display_name=\"Stored Messages\", name=\"stored_messages\", method=\"store_message\"),\n ]\n\n def store_message(self) -> Message:\n message = self.message\n\n message.session_id = self.session_id or message.session_id\n message.sender = self.sender or message.sender or MESSAGE_SENDER_AI\n message.sender_name = self.sender_name or message.sender_name or MESSAGE_SENDER_NAME_AI\n\n if self.memory:\n # override session_id\n self.memory.session_id = message.session_id\n lc_message = message.to_lc_message()\n self.memory.add_messages([lc_message])\n stored = self.memory.messages\n stored = [Message.from_lc_message(m) for m in stored]\n if message.sender:\n stored = [m for m in stored if m.sender == message.sender]\n else:\n store_message(message, flow_id=self.graph.flow_id)\n stored = get_messages(session_id=message.session_id, sender_name=message.sender_name, sender=message.sender)\n self.status = stored\n return stored\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"message":{"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":true,"placeholder":"","show":true,"name":"message","value":"","display_name":"Message","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The chat message to be stored.","title_case":false,"type":"str","_input_type":"MessageInput"},"sender":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender","value":"","display_name":"Sender","advanced":true,"dynamic":false,"info":"The sender of the message. Might be Machine or User. If empty, the current sender parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"},"sender_name":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"sender_name","value":"","display_name":"Sender Name","advanced":true,"dynamic":false,"info":"The name of the sender. Might be AI or User. If empty, the current sender parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"},"session_id":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"session_id","value":"yourSessionID","display_name":"Session ID","advanced":false,"dynamic":false,"info":"The session ID of the chat. If empty, the current session ID parameter will be used.","title_case":false,"type":"str","_input_type":"StrInput"}},"description":"Stores a chat message or text into Langflow tables or an external memory.","icon":"save","base_classes":["Message"],"display_name":"Store Message","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"stored_messages","display_name":"Stored Messages","method":"store_message","value":"__UNDEFINED__","cache":true}],"field_order":["message","memory","sender","sender_name","session_id"],"beta":false,"edited":true,"metadata":{},"lf_version":"1.1.0"},"id":"StoreMessage-cQhUA"},"selected":false,"width":320,"height":387,"positionAbsolute":{"x":1486.239111832812,"y":-1223.5079325275838},"dragging":false},{"id":"OpenAIModel-lxK4T","type":"genericNode","position":{"x":2675.964957167353,"y":406.5467584439582},"data":{"type":"OpenAIModel","node":{"template":{"_type":"Component","output_parser":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"output_parser","value":"","display_name":"Output Parser","advanced":true,"input_types":["OutputParser"],"dynamic":false,"info":"The parser to use to parse the output of the model","title_case":false,"type":"other","_input_type":"HandleInput"},"api_key":{"load_from_db":true,"required":false,"placeholder":"","show":true,"name":"api_key","value":"","display_name":"OpenAI API Key","advanced":false,"input_types":["Message"],"dynamic":false,"info":"The OpenAI API Key to use for the OpenAI model.","title_case":false,"password":true,"type":"str","_input_type":"SecretStrInput"},"code":{"type":"code","required":true,"placeholder":"","list":false,"show":true,"multiline":true,"value":"import operator\nfrom functools import reduce\n\nfrom langchain_openai import ChatOpenAI\nfrom pydantic.v1 import SecretStr\n\nfrom langflow.base.models.model import LCModelComponent\nfrom langflow.base.models.openai_constants import OPENAI_MODEL_NAMES\nfrom langflow.field_typing import LanguageModel\nfrom langflow.field_typing.range_spec import RangeSpec\nfrom langflow.inputs import BoolInput, DictInput, DropdownInput, FloatInput, IntInput, SecretStrInput, StrInput\nfrom langflow.inputs.inputs import HandleInput\n\n\nclass OpenAIModelComponent(LCModelComponent):\n display_name = \"OpenAI\"\n description = \"Generates text using OpenAI LLMs.\"\n icon = \"OpenAI\"\n name = \"OpenAIModel\"\n\n inputs = [\n *LCModelComponent._base_inputs,\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n advanced=True,\n info=\"The maximum number of tokens to generate. Set to 0 for unlimited tokens.\",\n range_spec=RangeSpec(min=0, max=128000),\n ),\n DictInput(\n name=\"model_kwargs\",\n display_name=\"Model Kwargs\",\n advanced=True,\n info=\"Additional keyword arguments to pass to the model.\",\n ),\n BoolInput(\n name=\"json_mode\",\n display_name=\"JSON Mode\",\n advanced=True,\n info=\"If True, it will output JSON regardless of passing a schema.\",\n ),\n DictInput(\n name=\"output_schema\",\n is_list=True,\n display_name=\"Schema\",\n advanced=True,\n info=\"The schema for the Output of the model. \"\n \"You must pass the word JSON in the prompt. \"\n \"If left blank, JSON mode will be disabled. [DEPRECATED]\",\n ),\n DropdownInput(\n name=\"model_name\",\n display_name=\"Model Name\",\n advanced=False,\n options=OPENAI_MODEL_NAMES,\n value=OPENAI_MODEL_NAMES[0],\n ),\n StrInput(\n name=\"openai_api_base\",\n display_name=\"OpenAI API Base\",\n advanced=True,\n info=\"The base URL of the OpenAI API. \"\n \"Defaults to https://api.openai.com/v1. \"\n \"You can change this to use other APIs like JinaChat, LocalAI and Prem.\",\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"OpenAI API Key\",\n info=\"The OpenAI API Key to use for the OpenAI model.\",\n advanced=False,\n value=\"OPENAI_API_KEY\",\n ),\n FloatInput(name=\"temperature\", display_name=\"Temperature\", value=0.1),\n IntInput(\n name=\"seed\",\n display_name=\"Seed\",\n info=\"The seed controls the reproducibility of the job.\",\n advanced=True,\n value=1,\n ),\n HandleInput(\n name=\"output_parser\",\n display_name=\"Output Parser\",\n info=\"The parser to use to parse the output of the model\",\n advanced=True,\n input_types=[\"OutputParser\"],\n ),\n ]\n\n def build_model(self) -> LanguageModel: # type: ignore[type-var]\n # self.output_schema is a list of dictionaries\n # let's convert it to a dictionary\n output_schema_dict: dict[str, str] = reduce(operator.ior, self.output_schema or {}, {})\n openai_api_key = self.api_key\n temperature = self.temperature\n model_name: str = self.model_name\n max_tokens = self.max_tokens\n model_kwargs = self.model_kwargs or {}\n openai_api_base = self.openai_api_base or \"https://api.openai.com/v1\"\n json_mode = bool(output_schema_dict) or self.json_mode\n seed = self.seed\n\n api_key = SecretStr(openai_api_key).get_secret_value() if openai_api_key else None\n output = ChatOpenAI(\n max_tokens=max_tokens or None,\n model_kwargs=model_kwargs,\n model=model_name,\n base_url=openai_api_base,\n api_key=api_key,\n temperature=temperature if temperature is not None else 0.1,\n seed=seed,\n )\n if json_mode:\n if output_schema_dict:\n output = output.with_structured_output(schema=output_schema_dict, method=\"json_mode\")\n else:\n output = output.bind(response_format={\"type\": \"json_object\"})\n\n return output\n\n def _get_exception_message(self, e: Exception):\n \"\"\"Get a message from an OpenAI exception.\n\n Args:\n e (Exception): The exception to get the message from.\n\n Returns:\n str: The message from the exception.\n \"\"\"\n try:\n from openai import BadRequestError\n except ImportError:\n return None\n if isinstance(e, BadRequestError):\n message = e.body.get(\"message\")\n if message:\n return message\n return None\n","fileTypes":[],"file_path":"","password":false,"name":"code","advanced":true,"dynamic":true,"info":"","load_from_db":false,"title_case":false},"input_value":{"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"input_value","value":"","display_name":"Input","advanced":false,"input_types":["Message"],"dynamic":false,"info":"","title_case":false,"type":"str","_input_type":"MessageInput"},"json_mode":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"json_mode","value":false,"display_name":"JSON Mode","advanced":true,"dynamic":false,"info":"If True, it will output JSON regardless of passing a schema.","title_case":false,"type":"bool","_input_type":"BoolInput"},"max_tokens":{"trace_as_metadata":true,"range_spec":{"step_type":"float","min":0,"max":128000,"step":0.1},"list":false,"required":false,"placeholder":"","show":true,"name":"max_tokens","value":"","display_name":"Max Tokens","advanced":true,"dynamic":false,"info":"The maximum number of tokens to generate. Set to 0 for unlimited tokens.","title_case":false,"type":"int","_input_type":"IntInput"},"model_kwargs":{"trace_as_input":true,"list":false,"required":false,"placeholder":"","show":true,"name":"model_kwargs","value":{},"display_name":"Model Kwargs","advanced":true,"dynamic":false,"info":"Additional keyword arguments to pass to the model.","title_case":false,"type":"dict","_input_type":"DictInput"},"model_name":{"tool_mode":false,"trace_as_metadata":true,"options":["gpt-4o-mini","gpt-4o","gpt-4-turbo","gpt-4-turbo-preview","gpt-4","gpt-3.5-turbo","gpt-3.5-turbo-0125"],"combobox":false,"required":false,"placeholder":"","show":true,"name":"model_name","value":"gpt-4o-mini","display_name":"Model Name","advanced":false,"dynamic":false,"info":"","title_case":false,"type":"str","_input_type":"DropdownInput","load_from_db":false},"openai_api_base":{"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"openai_api_base","value":"","display_name":"OpenAI API Base","advanced":true,"dynamic":false,"info":"The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.","title_case":false,"type":"str","_input_type":"StrInput"},"output_schema":{"trace_as_input":true,"list":true,"required":false,"placeholder":"","show":true,"name":"output_schema","value":{},"display_name":"Schema","advanced":true,"dynamic":false,"info":"The schema for the Output of the model. You must pass the word JSON in the prompt. If left blank, JSON mode will be disabled. [DEPRECATED]","title_case":false,"type":"dict","_input_type":"DictInput"},"seed":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"seed","value":1,"display_name":"Seed","advanced":true,"dynamic":false,"info":"The seed controls the reproducibility of the job.","title_case":false,"type":"int","_input_type":"IntInput"},"stream":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"stream","value":false,"display_name":"Stream","advanced":false,"dynamic":false,"info":"Stream the response from the model. Streaming works only in Chat.","title_case":false,"type":"bool","_input_type":"BoolInput"},"system_message":{"tool_mode":false,"trace_as_input":true,"trace_as_metadata":true,"load_from_db":false,"list":false,"required":false,"placeholder":"","show":true,"name":"system_message","value":"","display_name":"System Message","advanced":false,"input_types":["Message"],"dynamic":false,"info":"System message to pass to the model.","title_case":false,"type":"str","_input_type":"MessageTextInput"},"temperature":{"trace_as_metadata":true,"list":false,"required":false,"placeholder":"","show":true,"name":"temperature","value":0.1,"display_name":"Temperature","advanced":false,"dynamic":false,"info":"","title_case":false,"type":"float","_input_type":"FloatInput"}},"description":"Generates text using OpenAI LLMs.","icon":"OpenAI","base_classes":["LanguageModel","Message"],"display_name":"OpenAI","documentation":"","custom_fields":{},"output_types":[],"pinned":false,"conditional_paths":[],"frozen":false,"outputs":[{"types":["Message"],"selected":"Message","name":"text_output","display_name":"Text","method":"text_response","value":"__UNDEFINED__","cache":true,"required_inputs":[]},{"types":["LanguageModel"],"selected":"LanguageModel","name":"model_output","display_name":"Language Model","method":"build_model","value":"__UNDEFINED__","cache":true,"required_inputs":[],"hidden":true}],"field_order":["input_value","system_message","stream","max_tokens","model_kwargs","json_mode","output_schema","model_name","openai_api_base","api_key","temperature","seed","output_parser"],"beta":false,"legacy":false,"edited":false,"metadata":{},"tool_mode":false,"lf_version":"1.1.0"},"id":"OpenAIModel-lxK4T","description":"Generates text using OpenAI LLMs.","display_name":"OpenAI"},"selected":false,"width":320,"height":623,"positionAbsolute":{"x":2675.964957167353,"y":406.5467584439582},"dragging":false},{"id":"note-LVfRE","type":"noteNode","position":{"x":1559.3777851357563,"y":-1314.6647525330593},"data":{"node":{"description":"# Store message (user input)","display_name":"","documentation":"","template":{"backgroundColor":"amber"}},"type":"note","id":"note-LVfRE"},"selected":false,"width":324,"height":324,"positionAbsolute":{"x":1559.3777851357563,"y":-1314.6647525330593},"dragging":false,"style":{"width":324,"height":324},"resizing":false},{"id":"note-6FUWv","type":"noteNode","position":{"x":1811.9293229495097,"y":-433.6225906127927},"data":{"node":{"description":"# How many messages to send to context?","display_name":"","documentation":"","template":{"backgroundColor":"transparent"}},"type":"note","id":"note-6FUWv"},"selected":false,"width":324,"height":324,"positionAbsolute":{"x":1811.9293229495097,"y":-433.6225906127927},"dragging":false,"style":{"width":324,"height":324},"resizing":false},{"id":"note-RW7kv","type":"noteNode","position":{"x":1560.8459731481148,"y":-1797.0415002147981},"data":{"node":{"description":"# Store message (bot answer)","display_name":"","documentation":"","template":{"backgroundColor":"amber"}},"type":"note","id":"note-RW7kv"},"selected":false,"width":324,"height":324,"positionAbsolute":{"x":1560.8459731481148,"y":-1797.0415002147981},"dragging":false,"style":{"width":324,"height":324},"resizing":false},{"id":"note-A4yDm","type":"noteNode","position":{"x":624.2254878272629,"y":635.7791994485383},"data":{"node":{"description":"# User question (input)","display_name":"","documentation":"","template":{"backgroundColor":"lime"}},"type":"note","id":"note-A4yDm"},"selected":false,"width":325,"height":324,"positionAbsolute":{"x":624.2254878272629,"y":635.7791994485383},"dragging":false,"style":{"width":325,"height":324},"resizing":false},{"id":"note-R9ONa","type":"noteNode","position":{"x":1982.4149154738998,"y":123.04272176864498},"data":{"node":{"description":"# Inject chat history into prompt context\n\n# ↓","display_name":"","documentation":"","template":{"backgroundColor":"transparent"}},"type":"note","id":"note-R9ONa"},"selected":false,"width":324,"height":324,"positionAbsolute":{"x":1982.4149154738998,"y":123.04272176864498},"dragging":false,"style":{"width":324,"height":324},"resizing":false},{"id":"note-e7JCu","type":"noteNode","position":{"x":2229.3284034502517,"y":378.47672782279847},"data":{"node":{"description":"# Inject vector store response into prompt context","display_name":"","documentation":"","template":{"backgroundColor":"rose"}},"type":"note","id":"note-e7JCu"},"selected":false,"width":324,"height":324,"positionAbsolute":{"x":2229.3284034502517,"y":378.47672782279847},"dragging":false,"style":{"width":324,"height":324},"resizing":false},{"id":"note-ClFdf","type":"noteNode","position":{"x":3399.3359496952708,"y":643.3788825676193},"data":{"node":{"description":"# Bot response (output)","display_name":"","documentation":"","template":{"backgroundColor":"lime"}},"type":"note","id":"note-ClFdf"},"selected":false,"width":325,"height":325,"positionAbsolute":{"x":3399.3359496952708,"y":643.3788825676193},"dragging":false},{"id":"note-DWJct","type":"noteNode","position":{"x":864.8020984037155,"y":-1564.786262149919},"data":{"node":{"description":"# Astra DB Collection for storage","display_name":"","documentation":"","template":{"backgroundColor":"amber"}},"type":"note","id":"note-DWJct"},"selected":false,"width":325,"height":325,"positionAbsolute":{"x":864.8020984037155,"y":-1564.786262149919},"dragging":false},{"id":"note-SF2ao","type":"noteNode","position":{"x":1233.0841759964044,"y":34.28634851916749},"data":{"node":{"description":"# Retrieve vector similarity results","display_name":"","documentation":"","template":{"backgroundColor":"rose"}},"type":"note","id":"note-SF2ao"},"selected":false,"width":349,"height":324,"positionAbsolute":{"x":1233.0841759964044,"y":34.28634851916749},"dragging":false,"style":{"width":349,"height":324},"resizing":false},{"id":"note-Yyt4U","type":"noteNode","position":{"x":2757.5434555619913,"y":290.9507013917443},"data":{"node":{"description":"# Instruct the LLM to give a nice response","display_name":"","documentation":"","template":{"backgroundColor":"rose"}},"type":"note","id":"note-Yyt4U"},"selected":false,"width":325,"height":325,"positionAbsolute":{"x":2757.5434555619913,"y":290.9507013917443},"dragging":false},{"id":"note-enOnH","type":"noteNode","position":{"x":1550.7433670432288,"y":-769.4444918828574},"data":{"node":{"description":"# Retrieve history (user & bot)\n# ↓\n","display_name":"","documentation":"","template":{"backgroundColor":"amber"}},"type":"note","id":"note-enOnH"},"selected":false,"width":325,"height":325,"positionAbsolute":{"x":1550.7433670432288,"y":-769.4444918828574},"dragging":false}],"edges":[{"className":"","data":{"sourceHandle":{"dataType":"ChatInput","id":"ChatInput-c2hnf","name":"message","output_types":["Message"]},"targetHandle":{"fieldName":"question","id":"Prompt-pe8Ic","inputTypes":["Message","Text"],"type":"str"}},"id":"reactflow__edge-ChatInput-c2hnf{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt-pe8Ic{œfieldNameœ:œquestionœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","source":"ChatInput-c2hnf","sourceHandle":"{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}","target":"Prompt-pe8Ic","targetHandle":"{œfieldNameœ:œquestionœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","animated":false},{"source":"ChatInput-c2hnf","sourceHandle":"{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}","target":"AstraDB-m7obA","targetHandle":"{œfieldNameœ:œsearch_inputœ,œidœ:œAstraDB-m7obAœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"search_input","id":"AstraDB-m7obA","inputTypes":["Message"],"type":"str"},"sourceHandle":{"dataType":"ChatInput","id":"ChatInput-c2hnf","name":"message","output_types":["Message"]}},"id":"reactflow__edge-ChatInput-c2hnf{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-AstraDB-m7obA{œfieldNameœ:œsearch_inputœ,œidœ:œAstraDB-m7obAœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"AstraDB-m7obA","sourceHandle":"{œdataTypeœ:œAstraDBœ,œidœ:œAstraDB-m7obAœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}","target":"ParseData-wVfAN","targetHandle":"{œfieldNameœ:œdataœ,œidœ:œParseData-wVfANœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}","data":{"targetHandle":{"fieldName":"data","id":"ParseData-wVfAN","inputTypes":["Data"],"type":"other"},"sourceHandle":{"dataType":"AstraDB","id":"AstraDB-m7obA","name":"search_results","output_types":["Data"]}},"id":"reactflow__edge-AstraDB-m7obA{œdataTypeœ:œAstraDBœ,œidœ:œAstraDB-m7obAœ,œnameœ:œsearch_resultsœ,œoutput_typesœ:[œDataœ]}-ParseData-wVfAN{œfieldNameœ:œdataœ,œidœ:œParseData-wVfANœ,œinputTypesœ:[œDataœ],œtypeœ:œotherœ}","className":"","animated":false},{"source":"AstraDBChatMemory-9Hqar","sourceHandle":"{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}","target":"Memory-4WDcV","targetHandle":"{œfieldNameœ:œmemoryœ,œidœ:œMemory-4WDcVœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","data":{"targetHandle":{"fieldName":"memory","id":"Memory-4WDcV","inputTypes":["BaseChatMessageHistory"],"type":"other"},"sourceHandle":{"dataType":"AstraDBChatMemory","id":"AstraDBChatMemory-9Hqar","name":"memory","output_types":["BaseChatMessageHistory"]}},"id":"reactflow__edge-AstraDBChatMemory-9Hqar{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}-Memory-4WDcV{œfieldNameœ:œmemoryœ,œidœ:œMemory-4WDcVœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","className":"","animated":false},{"source":"AstraDBChatMemory-9Hqar","sourceHandle":"{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}","target":"StoreMessage-udpOG","targetHandle":"{œfieldNameœ:œmemoryœ,œidœ:œStoreMessage-udpOGœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","data":{"targetHandle":{"fieldName":"memory","id":"StoreMessage-udpOG","inputTypes":["BaseChatMessageHistory"],"type":"other"},"sourceHandle":{"dataType":"AstraDBChatMemory","id":"AstraDBChatMemory-9Hqar","name":"memory","output_types":["BaseChatMessageHistory"]}},"id":"reactflow__edge-AstraDBChatMemory-9Hqar{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}-StoreMessage-udpOG{œfieldNameœ:œmemoryœ,œidœ:œStoreMessage-udpOGœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","className":"","animated":false},{"source":"ChatOutput-Jcmxm","sourceHandle":"{œdataTypeœ:œChatOutputœ,œidœ:œChatOutput-Jcmxmœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}","target":"StoreMessage-udpOG","targetHandle":"{œfieldNameœ:œmessageœ,œidœ:œStoreMessage-udpOGœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"message","id":"StoreMessage-udpOG","inputTypes":["Message"],"type":"str"},"sourceHandle":{"dataType":"ChatOutput","id":"ChatOutput-Jcmxm","name":"message","output_types":["Message"]}},"id":"reactflow__edge-ChatOutput-Jcmxm{œdataTypeœ:œChatOutputœ,œidœ:œChatOutput-Jcmxmœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-StoreMessage-udpOG{œfieldNameœ:œmessageœ,œidœ:œStoreMessage-udpOGœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"ParseData-wVfAN","sourceHandle":"{œdataTypeœ:œParseDataœ,œidœ:œParseData-wVfANœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}","target":"Prompt-pe8Ic","targetHandle":"{œfieldNameœ:œcontextœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"context","id":"Prompt-pe8Ic","inputTypes":["Message","Text"],"type":"str"},"sourceHandle":{"dataType":"ParseData","id":"ParseData-wVfAN","name":"text","output_types":["Message"]}},"id":"reactflow__edge-ParseData-wVfAN{œdataTypeœ:œParseDataœ,œidœ:œParseData-wVfANœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt-pe8Ic{œfieldNameœ:œcontextœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"Memory-4WDcV","sourceHandle":"{œdataTypeœ:œMemoryœ,œidœ:œMemory-4WDcVœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}","target":"Prompt-pe8Ic","targetHandle":"{œfieldNameœ:œchat_historyœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"chat_history","id":"Prompt-pe8Ic","inputTypes":["Message","Text"],"type":"str"},"sourceHandle":{"dataType":"Memory","id":"Memory-4WDcV","name":"messages_text","output_types":["Message"]}},"id":"reactflow__edge-Memory-4WDcV{œdataTypeœ:œMemoryœ,œidœ:œMemory-4WDcVœ,œnameœ:œmessages_textœ,œoutput_typesœ:[œMessageœ]}-Prompt-pe8Ic{œfieldNameœ:œchat_historyœ,œidœ:œPrompt-pe8Icœ,œinputTypesœ:[œMessageœ,œTextœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"ChatInput-c2hnf","sourceHandle":"{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}","target":"StoreMessage-cQhUA","targetHandle":"{œfieldNameœ:œmessageœ,œidœ:œStoreMessage-cQhUAœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"message","id":"StoreMessage-cQhUA","inputTypes":["Message"],"type":"str"},"sourceHandle":{"dataType":"ChatInput","id":"ChatInput-c2hnf","name":"message","output_types":["Message"]}},"id":"reactflow__edge-ChatInput-c2hnf{œdataTypeœ:œChatInputœ,œidœ:œChatInput-c2hnfœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-StoreMessage-cQhUA{œfieldNameœ:œmessageœ,œidœ:œStoreMessage-cQhUAœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"AstraDBChatMemory-9Hqar","sourceHandle":"{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}","target":"StoreMessage-cQhUA","targetHandle":"{œfieldNameœ:œmemoryœ,œidœ:œStoreMessage-cQhUAœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","data":{"targetHandle":{"fieldName":"memory","id":"StoreMessage-cQhUA","inputTypes":["BaseChatMessageHistory"],"type":"other"},"sourceHandle":{"dataType":"AstraDBChatMemory","id":"AstraDBChatMemory-9Hqar","name":"memory","output_types":["BaseChatMessageHistory"]}},"id":"reactflow__edge-AstraDBChatMemory-9Hqar{œdataTypeœ:œAstraDBChatMemoryœ,œidœ:œAstraDBChatMemory-9Hqarœ,œnameœ:œmemoryœ,œoutput_typesœ:[œBaseChatMessageHistoryœ]}-StoreMessage-cQhUA{œfieldNameœ:œmemoryœ,œidœ:œStoreMessage-cQhUAœ,œinputTypesœ:[œBaseChatMessageHistoryœ],œtypeœ:œotherœ}","className":"","animated":false},{"source":"Prompt-pe8Ic","sourceHandle":"{œdataTypeœ:œPromptœ,œidœ:œPrompt-pe8Icœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}","target":"OpenAIModel-lxK4T","targetHandle":"{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-lxK4Tœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"input_value","id":"OpenAIModel-lxK4T","inputTypes":["Message"],"type":"str"},"sourceHandle":{"dataType":"Prompt","id":"Prompt-pe8Ic","name":"prompt","output_types":["Message"]}},"id":"reactflow__edge-Prompt-pe8Ic{œdataTypeœ:œPromptœ,œidœ:œPrompt-pe8Icœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-OpenAIModel-lxK4T{œfieldNameœ:œinput_valueœ,œidœ:œOpenAIModel-lxK4Tœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","className":"","animated":false},{"source":"OpenAIModel-lxK4T","sourceHandle":"{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-lxK4Tœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}","target":"ChatOutput-Jcmxm","targetHandle":"{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-Jcmxmœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","data":{"targetHandle":{"fieldName":"input_value","id":"ChatOutput-Jcmxm","inputTypes":["Message"],"type":"str"},"sourceHandle":{"dataType":"OpenAIModel","id":"OpenAIModel-lxK4T","name":"text_output","output_types":["Message"]}},"id":"reactflow__edge-OpenAIModel-lxK4T{œdataTypeœ:œOpenAIModelœ,œidœ:œOpenAIModel-lxK4Tœ,œnameœ:œtext_outputœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-Jcmxm{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-Jcmxmœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}","className":"","animated":false}],"viewport":{"x":-143.87888179015158,"y":98.69367480439388,"zoom":0.41976891529183935}},"description":"Building Intelligent Interactions.","name":"Zoom_Astra_RAG_GenAI_Flow","last_tested_version":"1.1.0","endpoint_name":"zoom_ai_bot","is_component":false}