228 lines
No EOL
12 KiB
JSON
228 lines
No EOL
12 KiB
JSON
{
|
|
"id": "40b2ae66-384b-4978-85ab-f79706287a1a",
|
|
"data": {
|
|
"nodes": [
|
|
{
|
|
"id": "CustomComponent-xbSW2",
|
|
"type": "genericNode",
|
|
"position": {
|
|
"x": 888.0012384532345,
|
|
"y": 274.9520639008431
|
|
},
|
|
"data": {
|
|
"type": "CustomComponent",
|
|
"node": {
|
|
"template": {
|
|
"_type": "Component",
|
|
"code": {
|
|
"type": "code",
|
|
"required": true,
|
|
"placeholder": "",
|
|
"list": false,
|
|
"show": true,
|
|
"multiline": true,
|
|
"value": "# from langflow.field_typing import Data\nfrom langflow.custom import Component\nfrom langflow.io import StrInput\nfrom langflow.schema import Data\nfrom langflow.io import Output\n\n\nclass CustomComponent(Component):\n display_name = \"Custom Component\"\n description = \"Use as a template to create your own component.\"\n documentation: str = \"http://docs.langflow.org/components/custom\"\n icon = \"custom_components\"\n\n inputs = [\n StrInput(name=\"input_value\", display_name=\"Input Value\", value=\"Hello, World!\", input_types=[\"Data\"]),\n ]\n\n outputs = [\n Output(display_name=\"Output\", name=\"output\", method=\"build_output\"),\n ]\n\n def build_output(self) -> Data:\n if isinstance(self.input_value, Data):\n data = self.input_value\n else:\n data = Data(value=self.input_value)\n \n if \"path\" in data:\n path = self.resolve_path(data.path)\n path_obj = Path(path)\n with open(path, \"w\") as f:\n f.write(data.model_dump())\n self.status = data\n return data\n",
|
|
"fileTypes": [],
|
|
"file_path": "",
|
|
"password": false,
|
|
"name": "code",
|
|
"advanced": true,
|
|
"dynamic": true,
|
|
"info": "",
|
|
"load_from_db": false,
|
|
"title_case": false
|
|
},
|
|
"input_value": {
|
|
"load_from_db": false,
|
|
"list": false,
|
|
"required": false,
|
|
"placeholder": "",
|
|
"show": true,
|
|
"value": "",
|
|
"name": "input_value",
|
|
"display_name": "Input Value",
|
|
"advanced": false,
|
|
"input_types": [
|
|
"Data"
|
|
],
|
|
"dynamic": false,
|
|
"info": "",
|
|
"title_case": false,
|
|
"type": "str"
|
|
}
|
|
},
|
|
"description": "Use as a template to create your own component.",
|
|
"icon": "custom_components",
|
|
"base_classes": [
|
|
"Data"
|
|
],
|
|
"display_name": "Custom Component",
|
|
"documentation": "http://docs.langflow.org/components/custom",
|
|
"custom_fields": {},
|
|
"output_types": [],
|
|
"pinned": false,
|
|
"conditional_paths": [],
|
|
"frozen": false,
|
|
"outputs": [
|
|
{
|
|
"types": [
|
|
"Data"
|
|
],
|
|
"selected": "Data",
|
|
"name": "output",
|
|
"display_name": "Output",
|
|
"method": "build_output",
|
|
"value": "__UNDEFINED__",
|
|
"cache": true
|
|
}
|
|
],
|
|
"field_order": [
|
|
"input_value"
|
|
],
|
|
"beta": false,
|
|
"edited": true
|
|
},
|
|
"id": "CustomComponent-xbSW2",
|
|
"description": "Use as a template to create your own component.",
|
|
"display_name": "Custom Component"
|
|
},
|
|
"selected": false,
|
|
"width": 384,
|
|
"height": 337,
|
|
"positionAbsolute": {
|
|
"x": 888.0012384532345,
|
|
"y": 274.9520639008431
|
|
},
|
|
"dragging": false
|
|
},
|
|
{
|
|
"id": "Webhook-eeCWO",
|
|
"type": "genericNode",
|
|
"position": {
|
|
"x": 418,
|
|
"y": 270.2890625
|
|
},
|
|
"data": {
|
|
"type": "Webhook",
|
|
"node": {
|
|
"template": {
|
|
"_type": "Component",
|
|
"code": {
|
|
"type": "code",
|
|
"required": true,
|
|
"placeholder": "",
|
|
"list": false,
|
|
"show": true,
|
|
"multiline": true,
|
|
"value": "import json\n\nfrom langflow.custom import Component\nfrom langflow.io import MultilineInput\nfrom langflow.schema import Data\nfrom langflow.io import Output\n\n\nclass WebhookComponent(Component):\n display_name = \"Webhook Input\"\n description = \"Defines a webhook input for the flow.\"\n\n inputs = [\n MultilineInput(\n name=\"data\",\n display_name=\"Data\",\n info=\"Use this field to quickly test the webhook component by providing a JSON payload.\",\n multiline=True,\n )\n ]\n outputs = [\n Output(display_name=\"Data\", name=\"output_data\", method=\"build_data\"),\n ]\n\n def build_data(self) -> Data:\n message = \"\"\n if not self.data:\n self.status = \"No data provided.\"\n return Data(data={})\n try:\n body = json.loads(self.data or \"{}\")\n except json.JSONDecodeError:\n body = {\"payload\": self.data}\n message = f\"Invalid JSON payload. Please check the format.\\n\\n{self.data}\"\n data = Data(data=body)\n if not message:\n message = data\n self.status = message\n return data\n",
|
|
"fileTypes": [],
|
|
"file_path": "",
|
|
"password": false,
|
|
"name": "code",
|
|
"advanced": true,
|
|
"dynamic": true,
|
|
"info": "",
|
|
"load_from_db": false,
|
|
"title_case": false
|
|
},
|
|
"data": {
|
|
"multiline": true,
|
|
"load_from_db": false,
|
|
"list": false,
|
|
"required": false,
|
|
"placeholder": "",
|
|
"show": true,
|
|
"value": "{\"test\":1}",
|
|
"name": "data",
|
|
"display_name": "Data",
|
|
"advanced": false,
|
|
"input_types": [
|
|
"Message"
|
|
],
|
|
"dynamic": false,
|
|
"info": "Use this field to quickly test the webhook component by providing a JSON payload.",
|
|
"title_case": false,
|
|
"type": "str"
|
|
}
|
|
},
|
|
"description": "Defines a webhook input for the flow.",
|
|
"base_classes": [
|
|
"Data"
|
|
],
|
|
"display_name": "Webhook Input",
|
|
"documentation": "",
|
|
"custom_fields": {},
|
|
"output_types": [],
|
|
"pinned": false,
|
|
"conditional_paths": [],
|
|
"frozen": false,
|
|
"outputs": [
|
|
{
|
|
"types": [
|
|
"Data"
|
|
],
|
|
"selected": "Data",
|
|
"name": "output_data",
|
|
"display_name": "Data",
|
|
"method": "build_data",
|
|
"value": "__UNDEFINED__",
|
|
"cache": true,
|
|
"hidden": false
|
|
}
|
|
],
|
|
"field_order": [
|
|
"data"
|
|
],
|
|
"beta": false
|
|
},
|
|
"id": "Webhook-eeCWO"
|
|
},
|
|
"selected": true,
|
|
"width": 384,
|
|
"height": 309,
|
|
"dragging": true,
|
|
"positionAbsolute": {
|
|
"x": 418,
|
|
"y": 270.2890625
|
|
}
|
|
}
|
|
],
|
|
"edges": [
|
|
{
|
|
"source": "Webhook-eeCWO",
|
|
"sourceHandle": "{œdataTypeœ:œWebhookœ,œidœ:œWebhook-eeCWOœ,œnameœ:œoutput_dataœ,œoutput_typesœ:[œDataœ]}",
|
|
"target": "CustomComponent-xbSW2",
|
|
"targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œCustomComponent-xbSW2œ,œinputTypesœ:[œDataœ],œtypeœ:œstrœ}",
|
|
"data": {
|
|
"targetHandle": {
|
|
"fieldName": "input_value",
|
|
"id": "CustomComponent-xbSW2",
|
|
"inputTypes": [
|
|
"Data"
|
|
],
|
|
"type": "str"
|
|
},
|
|
"sourceHandle": {
|
|
"dataType": "Webhook",
|
|
"id": "Webhook-eeCWO",
|
|
"name": "output_data",
|
|
"output_types": [
|
|
"Data"
|
|
]
|
|
}
|
|
},
|
|
"id": "reactflow__edge-Webhook-eeCWO{œdataTypeœ:œWebhookœ,œidœ:œWebhook-eeCWOœ,œnameœ:œoutput_dataœ,œoutput_typesœ:[œDataœ]}-CustomComponent-xbSW2{œfieldNameœ:œinput_valueœ,œidœ:œCustomComponent-xbSW2œ,œinputTypesœ:[œDataœ],œtypeœ:œstrœ}"
|
|
}
|
|
],
|
|
"viewport": {
|
|
"x": -243,
|
|
"y": -16,
|
|
"zoom": 1
|
|
}
|
|
},
|
|
"description": "The Power of Language at Your Fingertips.",
|
|
"name": "Webhook Test",
|
|
"last_tested_version": "1.0.0a59",
|
|
"endpoint_name": "webhook-test",
|
|
"is_component": false
|
|
} |