Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
3eb7cd6
Update pyproject versions
jordanrfrazier Aug 27, 2025
cc975df
fix: Avoid namespace collision for Astra (#9544)
erichare Aug 27, 2025
e423526
fix: Revert to a working composio release for module import (#9569)
erichare Aug 27, 2025
7fec73d
fix: Knowledge base component refactor (#9543)
erichare Aug 27, 2025
d8b5731
fix: Fix env file handling in Windows build scripts (#9414)
Cristhianzl Aug 27, 2025
49ddc8c
fix: update agent_llm display name to "Model Provider" in AgentCompon…
edwinjosechittilappilly Aug 27, 2025
e494afb
fix: use custom file handler on chat view, disable mcp_composer by de…
lucaseduoli Aug 27, 2025
48fe917
fix: Use the newest file component in Vector Store RAG Template (#9571)
erichare Aug 27, 2025
45512a5
fix: AI/ML icon is missing (#9553)
deon-sanchez Aug 27, 2025
d38e8f4
fix: Allow updates to the file component in templates using it (#9572)
erichare Aug 27, 2025
7a4bcfb
fix: Fixes filtering so legacy components aren't shown by default (#9…
mfortman11 Aug 27, 2025
e07d489
fix: changed name on tool mode to slug, added close button to sidebar…
lucaseduoli Aug 28, 2025
9e871e2
fix: enhance scroll behavior on playground (#9586)
lucaseduoli Aug 28, 2025
f792525
fix: delete duplicate Serper api from google bundle (#9601)
lucaseduoli Aug 28, 2025
d9c005b
fix: allow deletion of mcp servers, add tests for mcp sidebar (#9587)
lucaseduoli Aug 29, 2025
5860a8b
fix: change zoom in and out limit, create tests for zooming in and ou…
lucaseduoli Aug 29, 2025
f82e514
fix: Add localStorage persistence for feature toggles (#9597)
Cristhianzl Aug 29, 2025
b4e4435
fix: Add help text to Lock Flow option (#9600)
Cristhianzl Aug 29, 2025
2c21fbd
fix: Add comprehensive tests and improve minimal condition logic (#9611)
Cristhianzl Aug 29, 2025
133fe6c
fix: change icon color for mcp, remove color setting of icons (#9594)
lucaseduoli Aug 29, 2025
d715fa1
fix: remove unsupported styling options from chats components (#9610)
italojohnny Aug 29, 2025
9798500
fix: disable mcp auto install for not installed applications, refacto…
lucaseduoli Aug 29, 2025
349295a
fix: Properly allow the non-specification of an OCR Engine (#9617)
erichare Sep 1, 2025
dfd4037
fix: Support objects with data attribute in body processing (#9644)
Cristhianzl Sep 2, 2025
f8da854
fix: Add comprehensive message sorting + tests (#9641)
Cristhianzl Sep 2, 2025
cfd10f8
fix: Fix audio recording resource cleanup (#9623)
Cristhianzl Sep 2, 2025
f854b70
fix: Add voice mode availability detection (#9621)
Cristhianzl Sep 2, 2025
8b0ddde
fix: Remove formatting from agent input text content (#9638)
Cristhianzl Sep 2, 2025
9f09250
fix: added most important types at the beginning of the extensions ar…
lucaseduoli Sep 2, 2025
8d26d52
fix: Include flow ID in webhook URLs (#9624)
Cristhianzl Sep 2, 2025
169fd32
fix(logger): add optional cache to configure; update caching behavior…
ogabrielluiz Sep 2, 2025
d10854a
fix: Update sidebar border styles (#9625)
mfortman11 Sep 2, 2025
a290c46
fix: Remove top padding from sidebar groups (#9636)
Cristhianzl Sep 2, 2025
ea49ead
fix: disable message editing on playground, fix new session not persi…
lucaseduoli Sep 2, 2025
9d04d56
fix: disable elevate edges on node select (#9658)
lucaseduoli Sep 2, 2025
e61cb46
fix: Properly respect the order parameter for Message History (#9605)
erichare Sep 3, 2025
e20ff66
fix: Return multi-row dataframe when Structured Output data supports …
erichare Sep 3, 2025
68288aa
fix: apply to fields in settings page (#9602)
edwinjosechittilappilly Sep 3, 2025
617e94b
fix: Segmented Sidebar switch to search on value change (#9615)
mfortman11 Sep 3, 2025
d1998b3
fix: deprecate claude 3 sonnet model (#9622)
edwinjosechittilappilly Sep 3, 2025
375e672
fix: Properly import Langchain ToolMessage for Message options (#9675)
erichare Sep 3, 2025
032c7fa
fix: fixed user settings test (#9690)
lucaseduoli Sep 3, 2025
bc13c5b
fix: Remove warning log for unset TRACELOOP_API_KEY in configuration …
ogabrielluiz Sep 3, 2025
57686a7
fix: knowledge base fixes for 1.6 pointing to release branch (#9683)
deon-sanchez Sep 3, 2025
320cd00
fix: remove github link on discord button (#9655)
lucaseduoli Sep 4, 2025
d9a97cc
fix: remove python code component, fix placeholder not appearing (#9660)
lucaseduoli Sep 4, 2025
f51575e
fix: add margins to <p> tag in markdown (#9656)
lucaseduoli Sep 4, 2025
bf32bdd
fix: delete unused components, delete [deprecated] tag on the compone…
lucaseduoli Sep 4, 2025
74952e8
fix: Ensure correct Docling Remote URL for API (#9708)
erichare Sep 4, 2025
5687903
feat: remove agent dual output (#9700)
edwinjosechittilappilly Sep 4, 2025
3b7601f
refactor: Agent component enhancements for release v1.6 (#9685)
deon-sanchez Sep 4, 2025
b551b0c
feat: mcp composer integration (#9506)
jordanrfrazier Sep 5, 2025
f2f6129
fix: Adjust padding and layout for improved spacing (#9711)
Cristhianzl Sep 5, 2025
2f9dc00
fix: remove Groq from Agents model provider list (#9616)
edwinjosechittilappilly Sep 5, 2025
06e00c6
fix: conditional scheduling logic to not run branch (#9722)
jordanrfrazier Sep 8, 2025
1c262de
fix: disable keys when flow is locked (#9726)
lucaseduoli Sep 8, 2025
cf08d19
fix: superuser credential handling and AUTO_LOGIN security (#9542)
edwinjosechittilappilly Sep 8, 2025
6cabf2a
chore: Update version to 1.6.0 in package files (#9746)
ogabrielluiz Sep 8, 2025
d9c4802
fix: update logs position to be absolute (#9724)
lucaseduoli Sep 8, 2025
8cddf6c
fix: make entire playground chat area be clickable (#9721)
lucaseduoli Sep 8, 2025
86815cb
fix: Restore old description from file description. (#9752)
erichare Sep 8, 2025
5a8f988
fix: Preserve flows and components during project updates (#9750)
Cristhianzl Sep 9, 2025
c8e1efb
fix(langwatch): prevent trace errors with proper API key validation (…
italojohnny Sep 9, 2025
eed7a87
fix(URLComponent): filter out `None` in headers to avoid silent seria…
ogabrielluiz Sep 9, 2025
4bba723
fix: put knowledge bases under feature flag (#9749)
lucaseduoli Sep 9, 2025
ecd7214
refactor: Padding misaligned for sidebar icons and other issues fix f…
deon-sanchez Sep 9, 2025
b09964e
fix: Updated Agent Starter Projects with new Templates (#9772)
deon-sanchez Sep 9, 2025
17cb077
fix: remove agents from skipped components list in setup (#9785)
edwinjosechittilappilly Sep 9, 2025
a91ff1e
fix: improve error handling for missing OCR dependencies (#9753)
italojohnny Sep 9, 2025
938542b
fix: adjust casing on Add MCP Server buttons (#9774)
lucaseduoli Sep 9, 2025
56f4abc
fix: set gpt4.1 as default model (#9780)
edwinjosechittilappilly Sep 9, 2025
b0124e8
feat: double clicking a component will add it to the canvas (#9730)
deon-sanchez Sep 9, 2025
d700afd
fix: release branch tests (#9820)
jordanrfrazier Sep 11, 2025
10919ef
fix: Properly serialize documents for Graph RAG in Astra (#9777)
erichare Sep 11, 2025
aad68cf
fix: Standardize content dict format for LLM provider compatibility (…
Cristhianzl Sep 11, 2025
9749c0c
fix: make components added with filter come with the output pre-selec…
lucaseduoli Sep 11, 2025
2be9bb5
fix: make mcp tools refresh when changing server with the same name (…
lucaseduoli Sep 11, 2025
c95be64
fix: remove extra spaces from playground, added separator (#9779)
lucaseduoli Sep 11, 2025
6b332da
fix: Update message schema tests for image_url structure (#9823)
Cristhianzl Sep 11, 2025
28fc31f
fix: Restore Embedding Model Connections in Vector Store RAG (#9776)
erichare Sep 11, 2025
bfc7c8b
fix: update CORS configuration and add env vars to allow for user co…
jordanrfrazier Sep 11, 2025
481a921
fix: handle pandas Series in get_message boolean evaluation (#9765)
italojohnny Sep 11, 2025
f1ae031
fix: Add VLM support for Docling and improve deps (#9757)
erichare Sep 11, 2025
a97032a
fix: make cursor position not go to end on input list component (#9782)
lucaseduoli Sep 11, 2025
e58bc43
fix: remove metadata building to speed up load times (#9819)
ogabrielluiz Sep 12, 2025
5a104d1
fix: turn mcp composer feature on by default on frontend (#9831)
lucaseduoli Sep 12, 2025
6266b10
fix: make astra db component not disconnect, fix handle color when ty…
lucaseduoli Sep 12, 2025
36a6d48
fix: Handle ImportError for parse_api_endpoint and remove debug loggi…
ogabrielluiz Sep 12, 2025
ed19cb9
fix: make session_id visible in Message History Retrieve mode (#9557)
Vigtu Sep 12, 2025
fd88a3c
feat: Enhance logging configuration with caller information and condi…
ogabrielluiz Sep 12, 2025
567d0fa
ref: update auto login behavior to use secure defaults (#9825)
jordanrfrazier Sep 12, 2025
fbee06d
skip unimplemented cors tests
jordanrfrazier Sep 12, 2025
b6e2d09
fix: make mcp tools update when auth settings is null (#9844)
lucaseduoli Sep 12, 2025
d4f727a
fix: adjust tools title and description padding (#9847)
lucaseduoli Sep 12, 2025
6041389
fix: Apply a per-user uniqueness for mcp (#9840)
erichare Sep 12, 2025
8e266db
fix: make file button clickable after focusing on chat (#9863)
lucaseduoli Sep 15, 2025
839295d
fix: make input clickable on chat (#9864)
lucaseduoli Sep 15, 2025
11e9b1a
test: Increase loading performance test timeout (#9873)
Cristhianzl Sep 15, 2025
1918be1
Revert "ref: update auto login behavior to use secure defaults (#9825)"
jordanrfrazier Sep 15, 2025
75f34b3
refactor: update skip_auth_auto_login behavior and update messaging t…
jordanrfrazier Sep 15, 2025
75212fe
fix: Remove the uniqueness constraint on file names (#9872)
erichare Sep 15, 2025
09a2a61
Merge branch 'release-1.6.0' into merge/release-1.6.0-to-main
jordanrfrazier Sep 16, 2025
3860368
Move mcp composer service to lfx
jordanrfrazier Sep 16, 2025
60f5601
MCP Composer service factory fixes
jordanrfrazier Sep 16, 2025
c555ac1
Add back script changes for lfx
jordanrfrazier Sep 17, 2025
09e8f9b
Clean up mcp project imports
jordanrfrazier Sep 17, 2025
2d718cc
Update d37bc4322900_drop_single_constraint_on_files_name_.py
erichare Sep 17, 2025
d810add
Fix mcp imports
jordanrfrazier Sep 17, 2025
63c2c28
fix: Load flows autologin false (#9578)
phact Sep 17, 2025
a09dd24
Update CORS deprecation notice
jordanrfrazier Sep 17, 2025
2dce27a
Add back the external options in dropdown input
jordanrfrazier Sep 17, 2025
d7d859a
Add back starter projects
jordanrfrazier Sep 17, 2025
3efb092
Remove old components/data init file and update starter projects
jordanrfrazier Sep 17, 2025
9d92542
remove todo
jordanrfrazier Sep 17, 2025
bdd1d94
Re-adds the clean_data param for chat output
jordanrfrazier Sep 17, 2025
6a8cc75
merged main into 1.6.0
lucaseduoli Sep 17, 2025
64ba9c5
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 17, 2025
6ebb414
Update starter projects with clean_data
jordanrfrazier Sep 17, 2025
e757f62
Update oauth timeouts and fix socket binding check
jordanrfrazier Sep 17, 2025
3378502
Fix import and main duplicate code
jordanrfrazier Sep 18, 2025
4ac38ec
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 18, 2025
2e1506d
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Sep 18, 2025
3fa88bb
Import and test fixes
jordanrfrazier Sep 18, 2025
a3afcf6
Merge branch 'main' into merge/release-1.6.0-to-main
jordanrfrazier Sep 18, 2025
0bada8d
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 18, 2025
a7efa4b
Temporarily skipping knowledge bases import issue to allow other CI t…
jordanrfrazier Sep 18, 2025
5869a7d
Add python function to lfx test
jordanrfrazier Sep 18, 2025
c2890aa
fix: Move docling dependency into core dependencies instead of dev (#…
erichare Sep 18, 2025
e25e45b
fixed typesStore test
lucaseduoli Sep 18, 2025
5e9b9a0
Merge branch 'main' into merge/release-1.6.0-to-main
jordanrfrazier Sep 18, 2025
3fcbff7
Ruff and image unit test fixes
jordanrfrazier Sep 18, 2025
7d2450f
[autofix.ci] apply automated fixes
autofix-ci[bot] Sep 18, 2025
01dff70
📝 (image.py): Update function documentation to reflect changes in the…
Cristhianzl Sep 18, 2025
73264c4
merge fix
Cristhianzl Sep 18, 2025
0574ebc
Merge branch 'main' into merge/release-1.6.0-to-main
jordanrfrazier Sep 18, 2025
3871595
Knowledge bases update for merge
erichare Sep 18, 2025
67f61d5
Update __init__.py
erichare Sep 18, 2025
93bd2fd
Revert the changes to package lock
erichare Sep 18, 2025
64fc655
Fix kb tests to use client fixture instead of mocks
jordanrfrazier Sep 18, 2025
cb705c3
Clean up mcp init task
jordanrfrazier Sep 18, 2025
722ce3b
Fix other kb tests
jordanrfrazier Sep 18, 2025
38c918f
fix: Make sure strings can be parsed in the python interpreter (#9908)
erichare Sep 18, 2025
a46da1c
Merge branch 'release-1.6.0' into merge/release-1.6.0-to-main-v2
jordanrfrazier Sep 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update starter projects with clean_data
  • Loading branch information
jordanrfrazier committed Sep 17, 2025
commit 6ebb414935e16aed3aa45dd453cb4f2e38d8d33c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
"legacy": false,
"lf_version": "1.5.0",
"metadata": {
"code_hash": "e02b25a6d34d",
"code_hash": "ccda4dbe4ae1",
"dependencies": {
"dependencies": [
{
Expand Down Expand Up @@ -651,6 +651,24 @@
"pinned": false,
"template": {
"_type": "Component",
"clean_data": {
"_input_type": "BoolInput",
"advanced": true,
"display_name": "Basic Clean Data",
"dynamic": false,
"info": "Whether to clean data before converting to string.",
"list": false,
"list_add_label": "Add More",
"name": "clean_data",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"tool_mode": false,
"trace_as_metadata": true,
"type": "bool",
"value": true
},
"code": {
"advanced": true,
"dynamic": true,
Expand All @@ -667,7 +685,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "from collections.abc import Generator\nfrom typing import Any\n\nimport orjson\nfrom fastapi.encoders import jsonable_encoder\n\nfrom lfx.base.io.chat import ChatComponent\nfrom lfx.helpers.data import safe_convert\nfrom lfx.inputs.inputs import BoolInput, DropdownInput, HandleInput, MessageTextInput\nfrom lfx.schema.data import Data\nfrom lfx.schema.dataframe import DataFrame\nfrom lfx.schema.message import Message\nfrom lfx.schema.properties import Source\nfrom lfx.template.field.base import Output\nfrom lfx.utils.constants import (\n MESSAGE_SENDER_AI,\n MESSAGE_SENDER_NAME_AI,\n MESSAGE_SENDER_USER,\n)\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n documentation: str = \"https://docs.langflow.org/components-io#chat-output\"\n icon = \"MessagesSquare\"\n name = \"ChatOutput\"\n minimized = True\n\n inputs = [\n HandleInput(\n name=\"input_value\",\n display_name=\"Inputs\",\n info=\"Message to be passed as output.\",\n input_types=[\"Data\", \"DataFrame\", \"Message\"],\n required=True,\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 ]\n outputs = [\n Output(\n display_name=\"Output 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 # Handle case where source is a ChatOpenAI object\n if hasattr(source, \"model_name\"):\n source_dict[\"source\"] = source.model_name\n elif hasattr(source, \"model\"):\n source_dict[\"source\"] = str(source.model)\n else:\n source_dict[\"source\"] = str(source)\n return Source(**source_dict)\n\n async def message_response(self) -> Message:\n # First convert the input to string if needed\n text = self.convert_to_string()\n\n # Get source properties\n source, icon, display_name, source_id = self.get_properties_from_source_component()\n\n # Create or use existing Message object\n if isinstance(self.input_value, Message):\n message = self.input_value\n # Update message properties\n message.text = text\n else:\n message = Message(text=text)\n\n # Set message properties\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\n # Store message if needed\n if self.session_id and self.should_store_message:\n stored_message = await self.send_message(message)\n self.message.value = stored_message\n message = stored_message\n\n self.status = message\n return message\n\n def _serialize_data(self, data: Data) -> str:\n \"\"\"Serialize Data object to JSON string.\"\"\"\n # Convert data.data to JSON-serializable format\n serializable_data = jsonable_encoder(data.data)\n # Serialize with orjson, enabling pretty printing with indentation\n json_bytes = orjson.dumps(serializable_data, option=orjson.OPT_INDENT_2)\n # Convert bytes to string and wrap in Markdown code blocks\n return \"```json\\n\" + json_bytes.decode(\"utf-8\") + \"\\n```\"\n\n def _validate_input(self) -> None:\n \"\"\"Validate the input data and raise ValueError if invalid.\"\"\"\n if self.input_value is None:\n msg = \"Input data cannot be None\"\n raise ValueError(msg)\n if isinstance(self.input_value, list) and not all(\n isinstance(item, Message | Data | DataFrame | str) for item in self.input_value\n ):\n invalid_types = [\n type(item).__name__\n for item in self.input_value\n if not isinstance(item, Message | Data | DataFrame | str)\n ]\n msg = f\"Expected Data or DataFrame or Message or str, got {invalid_types}\"\n raise TypeError(msg)\n if not isinstance(\n self.input_value,\n Message | Data | DataFrame | str | list | Generator | type(None),\n ):\n type_name = type(self.input_value).__name__\n msg = f\"Expected Data or DataFrame or Message or str, Generator or None, got {type_name}\"\n raise TypeError(msg)\n\n def convert_to_string(self) -> str | Generator[Any, None, None]:\n \"\"\"Convert input data to string with proper error handling.\"\"\"\n self._validate_input()\n if isinstance(self.input_value, list):\n clean_data: bool = getattr(self, \"clean_data\", False)\n return \"\\n\".join([safe_convert(item, clean_data=clean_data) for item in self.input_value])\n if isinstance(self.input_value, Generator):\n return self.input_value\n return safe_convert(self.input_value)\n"
"value": "from collections.abc import Generator\nfrom typing import Any\n\nimport orjson\nfrom fastapi.encoders import jsonable_encoder\n\nfrom lfx.base.io.chat import ChatComponent\nfrom lfx.helpers.data import safe_convert\nfrom lfx.inputs.inputs import BoolInput, DropdownInput, HandleInput, MessageTextInput\nfrom lfx.schema.data import Data\nfrom lfx.schema.dataframe import DataFrame\nfrom lfx.schema.message import Message\nfrom lfx.schema.properties import Source\nfrom lfx.template.field.base import Output\nfrom lfx.utils.constants import (\n MESSAGE_SENDER_AI,\n MESSAGE_SENDER_NAME_AI,\n MESSAGE_SENDER_USER,\n)\n\n\nclass ChatOutput(ChatComponent):\n display_name = \"Chat Output\"\n description = \"Display a chat message in the Playground.\"\n documentation: str = \"https://docs.langflow.org/components-io#chat-output\"\n icon = \"MessagesSquare\"\n name = \"ChatOutput\"\n minimized = True\n\n inputs = [\n HandleInput(\n name=\"input_value\",\n display_name=\"Inputs\",\n info=\"Message to be passed as output.\",\n input_types=[\"Data\", \"DataFrame\", \"Message\"],\n required=True,\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 BoolInput(\n name=\"clean_data\",\n display_name=\"Basic Clean Data\",\n value=True,\n advanced=True,\n info=\"Whether to clean data before converting to string.\",\n ),\n ]\n outputs = [\n Output(\n display_name=\"Output 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 # Handle case where source is a ChatOpenAI object\n if hasattr(source, \"model_name\"):\n source_dict[\"source\"] = source.model_name\n elif hasattr(source, \"model\"):\n source_dict[\"source\"] = str(source.model)\n else:\n source_dict[\"source\"] = str(source)\n return Source(**source_dict)\n\n async def message_response(self) -> Message:\n # First convert the input to string if needed\n text = self.convert_to_string()\n\n # Get source properties\n source, icon, display_name, source_id = self.get_properties_from_source_component()\n\n # Create or use existing Message object\n if isinstance(self.input_value, Message):\n message = self.input_value\n # Update message properties\n message.text = text\n else:\n message = Message(text=text)\n\n # Set message properties\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\n # Store message if needed\n if self.session_id and self.should_store_message:\n stored_message = await self.send_message(message)\n self.message.value = stored_message\n message = stored_message\n\n self.status = message\n return message\n\n def _serialize_data(self, data: Data) -> str:\n \"\"\"Serialize Data object to JSON string.\"\"\"\n # Convert data.data to JSON-serializable format\n serializable_data = jsonable_encoder(data.data)\n # Serialize with orjson, enabling pretty printing with indentation\n json_bytes = orjson.dumps(serializable_data, option=orjson.OPT_INDENT_2)\n # Convert bytes to string and wrap in Markdown code blocks\n return \"```json\\n\" + json_bytes.decode(\"utf-8\") + \"\\n```\"\n\n def _validate_input(self) -> None:\n \"\"\"Validate the input data and raise ValueError if invalid.\"\"\"\n if self.input_value is None:\n msg = \"Input data cannot be None\"\n raise ValueError(msg)\n if isinstance(self.input_value, list) and not all(\n isinstance(item, Message | Data | DataFrame | str) for item in self.input_value\n ):\n invalid_types = [\n type(item).__name__\n for item in self.input_value\n if not isinstance(item, Message | Data | DataFrame | str)\n ]\n msg = f\"Expected Data or DataFrame or Message or str, got {invalid_types}\"\n raise TypeError(msg)\n if not isinstance(\n self.input_value,\n Message | Data | DataFrame | str | list | Generator | type(None),\n ):\n type_name = type(self.input_value).__name__\n msg = f\"Expected Data or DataFrame or Message or str, Generator or None, got {type_name}\"\n raise TypeError(msg)\n\n def convert_to_string(self) -> str | Generator[Any, None, None]:\n \"\"\"Convert input data to string with proper error handling.\"\"\"\n self._validate_input()\n if isinstance(self.input_value, list):\n clean_data: bool = getattr(self, \"clean_data\", False)\n return \"\\n\".join([safe_convert(item, clean_data=clean_data) for item in self.input_value])\n if isinstance(self.input_value, Generator):\n return self.input_value\n return safe_convert(self.input_value)\n"
},
"data_template": {
"_input_type": "MessageTextInput",
Expand Down
Loading
Loading