langflow/tests/data/WebhookTest.json

238 lines
No EOL
12 KiB
JSON

{
"id": "40b2ae66-384b-4978-85ab-f79706287a1a",
"data": {
"nodes": [
{
"id": "Webhook-8rYwr",
"type": "genericNode",
"position": {
"x": 375.90734417043643,
"y": 261.63442970852185
},
"data": {
"type": "Webhook",
"node": {
"template": {
"_type": "CustomComponent",
"code": {
"type": "code",
"required": true,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,
"value": "import json\nimport uuid\nfrom typing import Any, Optional\n\nfrom langflow.custom import CustomComponent\nfrom langflow.schema import Data\nfrom langflow.schema.dotdict import dotdict\n\n\nclass WebhookComponent(CustomComponent):\n display_name = \"Webhook Input\"\n description = \"Defines a webhook input for the flow.\"\n\n def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None):\n if field_name == \"webhook_id\":\n build_config[\"webhook_id\"][\"value\"] = uuid.uuid4().hex\n return build_config\n\n def build_config(self):\n return {\n \"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\n def build(self, data: Optional[str] = \"\") -> Data:\n message = \"\"\n try:\n body = json.loads(data or \"{}\")\n except json.JSONDecodeError:\n body = {\"payload\": data}\n message = f\"Invalid JSON payload. Please check the format.\\n\\n{data}\"\n record = Data(data=body)\n if not message:\n message = record\n self.status = message\n return record\n",
"fileTypes": [],
"file_path": "",
"password": false,
"name": "code",
"advanced": true,
"dynamic": true,
"info": "",
"load_from_db": false,
"title_case": false
},
"data": {
"type": "str",
"required": false,
"placeholder": "",
"list": false,
"show": true,
"multiline": true,
"value": "{\"bacon\":1}",
"fileTypes": [],
"file_path": "",
"password": false,
"name": "data",
"display_name": "Data",
"advanced": false,
"dynamic": false,
"info": "Use this field to quickly test the webhook component by providing a JSON payload.",
"load_from_db": false,
"title_case": false,
"input_types": [
"Text"
]
}
},
"description": "Defines a webhook input for the flow.",
"base_classes": [
"Data"
],
"display_name": "Webhook Input",
"documentation": "",
"custom_fields": {
"data": null
},
"output_types": [
"Data"
],
"pinned": false,
"conditional_paths": [],
"frozen": false,
"outputs": [
{
"types": [
"Data"
],
"selected": "Data",
"name": "data",
"hidden": false,
"display_name": "Data",
"method": null,
"value": "__UNDEFINED__",
"cache": true
}
],
"field_order": [],
"beta": false,
"edited": true
},
"id": "Webhook-8rYwr",
"description": "Defines a webhook input for the flow.",
"display_name": "Webhook Input",
"edited": false
},
"selected": false,
"width": 384,
"height": 309,
"dragging": false,
"positionAbsolute": {
"x": 375.90734417043643,
"y": 261.63442970852185
}
},
{
"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.inputs import StrInput\nfrom langflow.schema import Data\nfrom langflow.template 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_json())\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
}
],
"edges": [
{
"source": "Webhook-8rYwr",
"sourceHandle": "{œdataTypeœ:œWebhookœ,œidœ:œWebhook-8rYwrœ,œnameœ:œ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-8rYwr",
"name": "data",
"output_types": [
"Data"
]
}
},
"id": "reactflow__edge-Webhook-8rYwr{œdataTypeœ:œWebhookœ,œidœ:œWebhook-8rYwrœ,œnameœ:œdataœ,œoutput_typesœ:[œDataœ]}-CustomComponent-xbSW2{œfieldNameœ:œinput_valueœ,œidœ:œCustomComponent-xbSW2œ,œinputTypesœ:[œDataœ],œtypeœ:œstrœ}",
"className": ""
}
],
"viewport": {
"x": 0,
"y": 0,
"zoom": 1
}
},
"description": "The Power of Language at Your Fingertips.",
"name": "Webhook Test",
"last_tested_version": "1.0.0a52",
"endpoint_name": "webhook-test",
"is_component": false
}