fix: Rename AgentQL components and add prompt parameter (#6834)

* renamed components

* add prompt parameter

* [autofix.ci] apply automated fixes

* prevent both query and prompt

* ruff checks

* [autofix.ci] apply automated fixes

* amend conditional check

* change error message

* update templates

* [autofix.ci] apply automated fixes

* fix tags

* fix tags in news aggregator

---------

Co-authored-by: huwenjie912 <huwenjie912@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
wjwjtf 2025-03-12 23:36:18 -07:00 committed by GitHub
commit 2c0133d324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 178 additions and 132 deletions

View file

@ -14,8 +14,8 @@ from langflow.schema import Data
class AgentQL(Component):
display_name = "AgentQL Query Data"
description = "Uses AgentQL API to extract structured data from a given URL."
display_name = "Extract Web Data"
description = "Extracts structured data from a web page using an AgentQL query or a Natural Language description."
documentation: str = "https://docs.agentql.com/rest-api/api-reference"
icon = "AgentQL"
name = "AgentQL"
@ -23,23 +23,30 @@ class AgentQL(Component):
inputs = [
SecretStrInput(
name="api_key",
display_name="AgentQL API Key",
display_name="API Key",
required=True,
password=True,
info="Your AgentQL API key. Get one at https://dev.agentql.com.",
info="Your AgentQL API key from dev.agentql.com",
),
MessageTextInput(
name="url",
display_name="URL",
required=True,
info="The public URL of the webpage to extract data from.",
info="The URL of the public web page you want to extract data from.",
tool_mode=True,
),
MultilineInput(
name="query",
display_name="AgentQL Query",
required=True,
info="The AgentQL query to execute. Read more at https://docs.agentql.com/agentql-query.",
required=False,
info="The AgentQL query to execute. Learn more at https://docs.agentql.com/agentql-query or use a prompt.",
tool_mode=True,
),
MultilineInput(
name="prompt",
display_name="Prompt",
required=False,
info="A Natural Language description of the data to extract from the page. Alternative to AgentQL query.",
tool_mode=True,
),
IntInput(
@ -79,9 +86,17 @@ class AgentQL(Component):
payload = {
"url": self.url,
"query": self.query,
"prompt": self.prompt,
"params": self.params,
}
if not self.prompt and not self.query:
self.status = "Either Query or Prompt must be provided."
raise ValueError(self.status)
if self.prompt and self.query:
self.status = "Both Query and Prompt can't be provided at the same time."
raise ValueError(self.status)
try:
response = httpx.post(endpoint, headers=headers, json=payload, timeout=self.timeout)
response.raise_for_status()

View file

@ -23,40 +23,12 @@
}
},
"id": "reactflow__edge-AgentQL-XIw0m{œdataTypeœ:œAgentQLœ,œidœ:œAgentQL-XIw0mœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-O1xzr{œfieldNameœ:œtoolsœ,œidœ:œAgent-O1xzrœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}",
"selected": false,
"source": "AgentQL-XIw0m",
"sourceHandle": "{œdataTypeœ: œAgentQLœ, œidœ: œAgentQL-XIw0mœ, œnameœ: œcomponent_as_toolœ, œoutput_typesœ: [œToolœ]}",
"target": "Agent-O1xzr",
"targetHandle": "{œfieldNameœ: œtoolsœ, œidœ: œAgent-O1xzrœ, œinputTypesœ: [œToolœ], œtypeœ: œotherœ}"
},
{
"animated": false,
"className": "",
"data": {
"sourceHandle": {
"dataType": "Agent",
"id": "Agent-O1xzr",
"name": "response",
"output_types": [
"Message"
]
},
"targetHandle": {
"fieldName": "input_value",
"id": "ChatOutput-QiEpu",
"inputTypes": [
"Data",
"DataFrame",
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-Agent-O1xzr{œdataTypeœ:œAgentœ,œidœ:œAgent-O1xzrœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-QiEpu{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-QiEpuœ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œstrœ}",
"source": "Agent-O1xzr",
"sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-O1xzrœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-QiEpu",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-QiEpuœ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œstrœ}"
},
{
"animated": false,
"className": "",
@ -79,6 +51,7 @@
}
},
"id": "reactflow__edge-ChatInput-KdiYi{œdataTypeœ:œChatInputœ,œidœ:œChatInput-KdiYiœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Agent-O1xzr{œfieldNameœ:œinput_valueœ,œidœ:œAgent-O1xzrœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
"selected": false,
"source": "ChatInput-KdiYi",
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-KdiYiœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Agent-O1xzr",
@ -151,14 +124,15 @@
"beta": false,
"conditional_paths": [],
"custom_fields": {},
"description": "Uses AgentQL API to extract structured data from a given URL.",
"display_name": "AgentQL Query Data",
"description": "Extracts structured data from a web page using an AgentQL query or a Natural Language description.",
"display_name": "Extract Web Data",
"documentation": "https://docs.agentql.com/rest-api/api-reference",
"edited": false,
"field_order": [
"api_key",
"url",
"query",
"prompt",
"timeout",
"params"
],
@ -191,13 +165,13 @@
"api_key": {
"_input_type": "SecretStrInput",
"advanced": false,
"display_name": "AgentQL API Key",
"display_name": "API Key",
"dynamic": false,
"info": "Your AgentQL API key. Get one at https://dev.agentql.com.",
"info": "Your AgentQL API key from dev.agentql.com",
"input_types": [
"Message"
],
"load_from_db": false,
"load_from_db": true,
"name": "api_key",
"password": true,
"placeholder": "",
@ -223,7 +197,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "import httpx\nfrom loguru import logger\n\nfrom langflow.custom import Component\nfrom langflow.io import (\n DictInput,\n IntInput,\n MessageTextInput,\n MultilineInput,\n Output,\n SecretStrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AgentQL(Component):\n display_name = \"AgentQL Query Data\"\n description = \"Uses AgentQL API to extract structured data from a given URL.\"\n documentation: str = \"https://docs.agentql.com/rest-api/api-reference\"\n icon = \"AgentQL\"\n name = \"AgentQL\"\n\n inputs = [\n SecretStrInput(\n name=\"api_key\",\n display_name=\"AgentQL API Key\",\n required=True,\n password=True,\n info=\"Your AgentQL API key. Get one at https://dev.agentql.com.\",\n ),\n MessageTextInput(\n name=\"url\",\n display_name=\"URL\",\n required=True,\n info=\"The public URL of the webpage to extract data from.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"query\",\n display_name=\"AgentQL Query\",\n required=True,\n info=\"The AgentQL query to execute. Read more at https://docs.agentql.com/agentql-query.\",\n tool_mode=True,\n ),\n IntInput(\n name=\"timeout\",\n display_name=\"Timeout\",\n info=\"Timeout in seconds for the request. Increase if data extraction takes too long.\",\n value=900,\n advanced=True,\n ),\n DictInput(\n name=\"params\",\n display_name=\"Additional Params\",\n info=\"The additional params to send with the request. For details refer to https://docs.agentql.com/rest-api/api-reference#request-body.\",\n is_list=True,\n value={\n \"mode\": \"fast\",\n \"wait_for\": 0,\n \"is_scroll_to_bottom_enabled\": False,\n \"is_screenshot_enabled\": False,\n },\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"build_output\"),\n ]\n\n def build_output(self) -> Data:\n endpoint = \"https://api.agentql.com/v1/query-data\"\n headers = {\n \"X-API-Key\": self.api_key,\n \"Content-Type\": \"application/json\",\n \"X-TF-Request-Origin\": \"langflow\",\n }\n\n payload = {\n \"url\": self.url,\n \"query\": self.query,\n \"params\": self.params,\n }\n\n try:\n response = httpx.post(endpoint, headers=headers, json=payload, timeout=self.timeout)\n response.raise_for_status()\n\n json = response.json()\n data = Data(result=json[\"data\"], metadata=json[\"metadata\"])\n\n except httpx.HTTPStatusError as e:\n response = e.response\n if response.status_code in {401, 403}:\n self.status = \"Please, provide a valid API Key. You can create one at https://dev.agentql.com.\"\n else:\n try:\n error_json = response.json()\n logger.error(\n f\"Failure response: '{response.status_code} {response.reason_phrase}' with body: {error_json}\"\n )\n msg = error_json[\"error_info\"] if \"error_info\" in error_json else error_json[\"detail\"]\n except (ValueError, TypeError):\n msg = f\"HTTP {e}.\"\n self.status = msg\n raise ValueError(self.status) from e\n\n else:\n self.status = data\n return data\n"
"value": "import httpx\nfrom loguru import logger\n\nfrom langflow.custom import Component\nfrom langflow.io import (\n DictInput,\n IntInput,\n MessageTextInput,\n MultilineInput,\n Output,\n SecretStrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AgentQL(Component):\n display_name = \"Extract Web Data\"\n description = \"Extracts structured data from a web page using an AgentQL query or a Natural Language description.\"\n documentation: str = \"https://docs.agentql.com/rest-api/api-reference\"\n icon = \"AgentQL\"\n name = \"AgentQL\"\n\n inputs = [\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n required=True,\n password=True,\n info=\"Your AgentQL API key from dev.agentql.com\",\n ),\n MessageTextInput(\n name=\"url\",\n display_name=\"URL\",\n required=True,\n info=\"The URL of the public web page you want to extract data from.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"query\",\n display_name=\"AgentQL Query\",\n required=False,\n info=\"The AgentQL query to execute. Learn more at https://docs.agentql.com/agentql-query or use a prompt.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"prompt\",\n display_name=\"Prompt\",\n required=False,\n info=\"A Natural Language description of the data to extract from the page. Alternative to AgentQL query.\",\n tool_mode=True,\n ),\n IntInput(\n name=\"timeout\",\n display_name=\"Timeout\",\n info=\"Timeout in seconds for the request. Increase if data extraction takes too long.\",\n value=900,\n advanced=True,\n ),\n DictInput(\n name=\"params\",\n display_name=\"Additional Params\",\n info=\"The additional params to send with the request. For details refer to https://docs.agentql.com/rest-api/api-reference#request-body.\",\n is_list=True,\n value={\n \"mode\": \"fast\",\n \"wait_for\": 0,\n \"is_scroll_to_bottom_enabled\": False,\n \"is_screenshot_enabled\": False,\n },\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"build_output\"),\n ]\n\n def build_output(self) -> Data:\n endpoint = \"https://api.agentql.com/v1/query-data\"\n headers = {\n \"X-API-Key\": self.api_key,\n \"Content-Type\": \"application/json\",\n \"X-TF-Request-Origin\": \"langflow\",\n }\n\n payload = {\n \"url\": self.url,\n \"query\": self.query,\n \"prompt\": self.prompt,\n \"params\": self.params,\n }\n\n if not self.prompt and not self.query:\n self.status = \"Either Query or Prompt must be provided.\"\n raise ValueError(self.status)\n if self.prompt and self.query:\n self.status = \"Both Query and Prompt can't be provided at the same time.\"\n raise ValueError(self.status)\n\n try:\n response = httpx.post(endpoint, headers=headers, json=payload, timeout=self.timeout)\n response.raise_for_status()\n\n json = response.json()\n data = Data(result=json[\"data\"], metadata=json[\"metadata\"])\n\n except httpx.HTTPStatusError as e:\n response = e.response\n if response.status_code in {401, 403}:\n self.status = \"Please, provide a valid API Key. You can create one at https://dev.agentql.com.\"\n else:\n try:\n error_json = response.json()\n logger.error(\n f\"Failure response: '{response.status_code} {response.reason_phrase}' with body: {error_json}\"\n )\n msg = error_json[\"error_info\"] if \"error_info\" in error_json else error_json[\"detail\"]\n except (ValueError, TypeError):\n msg = f\"HTTP {e}.\"\n self.status = msg\n raise ValueError(self.status) from e\n\n else:\n self.status = data\n return data\n"
},
"params": {
"_input_type": "DictInput",
@ -248,12 +222,36 @@
"wait_for": 0
}
},
"prompt": {
"_input_type": "MultilineInput",
"advanced": false,
"display_name": "Prompt",
"dynamic": false,
"info": "A Natural Language description of the data to extract from the page. Alternative to AgentQL query.",
"input_types": [
"Message"
],
"list": false,
"list_add_label": "Add More",
"load_from_db": false,
"multiline": true,
"name": "prompt",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"tool_mode": true,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
"query": {
"_input_type": "MultilineInput",
"advanced": false,
"display_name": "AgentQL Query",
"dynamic": false,
"info": "The AgentQL query to execute. Read more at https://docs.agentql.com/agentql-query.",
"info": "The AgentQL query to execute. Learn more at https://docs.agentql.com/agentql-query or use a prompt.",
"input_types": [
"Message"
],
@ -263,7 +261,7 @@
"multiline": true,
"name": "query",
"placeholder": "",
"required": true,
"required": false,
"show": true,
"title_case": false,
"tool_mode": true,
@ -373,7 +371,7 @@
"type": "table",
"value": [
{
"description": "build_output(api_key: Message, query: Message, url: Message) - Uses AgentQL API to extract structured data from a given URL.",
"description": "build_output(api_key: Message, url: Message) - Extracts structured data from a web page using an AgentQL query or a Natural Language description.",
"name": "AgentQL-build_output",
"tags": [
"AgentQL-build_output"
@ -386,7 +384,7 @@
"advanced": false,
"display_name": "URL",
"dynamic": false,
"info": "The public URL of the webpage to extract data from.",
"info": "The URL of the public web page you want to extract data from.",
"input_types": [
"Message"
],
@ -413,7 +411,7 @@
"dragging": false,
"id": "AgentQL-XIw0m",
"measured": {
"height": 499,
"height": 599,
"width": 320
},
"position": {
@ -742,7 +740,6 @@
"Message"
],
"beta": false,
"category": "outputs",
"conditional_paths": [],
"custom_fields": {},
"description": "Display a chat message in the Playground.",
@ -758,13 +755,12 @@
"data_template",
"background_color",
"chat_icon",
"text_color"
"text_color",
"clean_data"
],
"frozen": false,
"icon": "MessagesSquare",
"key": "ChatOutput",
"legacy": false,
"lf_version": "1.2.0",
"metadata": {},
"minimized": true,
"output_types": [],
@ -784,7 +780,6 @@
}
],
"pinned": false,
"score": 0.007568328950209746,
"template": {
"_type": "Component",
"background_color": {
@ -893,7 +888,7 @@
"value": "{text}"
},
"input_value": {
"_input_type": "MessageInput",
"_input_type": "HandleInput",
"advanced": false,
"display_name": "Text",
"dynamic": false,
@ -905,16 +900,13 @@
],
"list": false,
"list_add_label": "Add More",
"load_from_db": false,
"name": "input_value",
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"tool_mode": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"type": "other",
"value": ""
},
"sender": {
@ -1054,7 +1046,6 @@
"Message"
],
"beta": false,
"category": "agents",
"conditional_paths": [],
"custom_fields": {},
"description": "Define the agent's instructions, then enter a task to complete using tools.",
@ -1091,9 +1082,7 @@
],
"frozen": false,
"icon": "bot",
"key": "Agent",
"legacy": false,
"lf_version": "1.2.0",
"metadata": {},
"minimized": false,
"output_types": [],
@ -1113,7 +1102,6 @@
}
],
"pinned": false,
"score": 1.1732828199964098e-19,
"template": {
"_type": "Component",
"add_current_date_tool": {
@ -1179,7 +1167,35 @@
"SambaNova",
"Custom"
],
"options_metadata": [],
"options_metadata": [
{
"icon": "Amazon"
},
{
"icon": "Anthropic"
},
{
"icon": "Azure"
},
{
"icon": "GoogleGenerativeAI"
},
{
"icon": "Groq"
},
{
"icon": "NVIDIA"
},
{
"icon": "OpenAI"
},
{
"icon": "SambaNova"
},
{
"icon": "brain"
}
],
"placeholder": "",
"real_time_refresh": true,
"required": false,
@ -1598,7 +1614,7 @@
"name": "temperature",
"placeholder": "",
"range_spec": {
"max": 2,
"max": 1,
"min": 0,
"step": 0.01,
"step_type": "float"
@ -1702,7 +1718,7 @@
"dragging": false,
"id": "Agent-O1xzr",
"measured": {
"height": 624,
"height": 621,
"width": 320
},
"position": {
@ -1740,18 +1756,18 @@
}
],
"viewport": {
"x": -185.56277678480728,
"y": 98.64473921569584,
"zoom": 1.3444274567846564
"x": -140.6486665710372,
"y": 68.92081829746667,
"zoom": 1.0230031993478927
}
},
"description": "Extracts data and information from webpages.",
"endpoint_name": null,
"icon": "Newspaper",
"id": "a5383bea-acb4-44ba-adeb-80c0fcb168b9",
"is_component": false,
"last_tested_version": "1.2.0",
"name": "News Aggregator",
"icon": "Newspaper",
"tags": [
"web-scraping",
"agents"

View file

@ -84,36 +84,6 @@
"sourceHandle": "{œdataTypeœ: œChatInputœ, œidœ: œChatInput-M0lPaœ, œnameœ: œmessageœ, œoutput_typesœ: [œMessageœ]}",
"target": "Agent-7PMCu",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œAgent-7PMCuœ, œinputTypesœ: [œMessageœ], œtypeœ: œstrœ}"
},
{
"animated": false,
"className": "",
"data": {
"sourceHandle": {
"dataType": "Agent",
"id": "Agent-7PMCu",
"name": "response",
"output_types": [
"Message"
]
},
"targetHandle": {
"fieldName": "input_value",
"id": "ChatOutput-LyZb7",
"inputTypes": [
"Data",
"DataFrame",
"Message"
],
"type": "str"
}
},
"id": "reactflow__edge-Agent-7PMCu{œdataTypeœ:œAgentœ,œidœ:œAgent-7PMCuœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-LyZb7{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-LyZb7œ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œstrœ}",
"selected": false,
"source": "Agent-7PMCu",
"sourceHandle": "{œdataTypeœ: œAgentœ, œidœ: œAgent-7PMCuœ, œnameœ: œresponseœ, œoutput_typesœ: [œMessageœ]}",
"target": "ChatOutput-LyZb7",
"targetHandle": "{œfieldNameœ: œinput_valueœ, œidœ: œChatOutput-LyZb7œ, œinputTypesœ: [œDataœ, œDataFrameœ, œMessageœ], œtypeœ: œstrœ}"
}
],
"nodes": [
@ -436,7 +406,6 @@
"Message"
],
"beta": false,
"category": "outputs",
"conditional_paths": [],
"custom_fields": {},
"description": "Display a chat message in the Playground.",
@ -452,13 +421,12 @@
"data_template",
"background_color",
"chat_icon",
"text_color"
"text_color",
"clean_data"
],
"frozen": false,
"icon": "MessagesSquare",
"key": "ChatOutput",
"legacy": false,
"lf_version": "1.2.0",
"metadata": {},
"minimized": true,
"output_types": [],
@ -478,7 +446,6 @@
}
],
"pinned": false,
"score": 0.00012027401062119145,
"template": {
"_type": "Component",
"background_color": {
@ -587,7 +554,7 @@
"value": "{text}"
},
"input_value": {
"_input_type": "MessageInput",
"_input_type": "HandleInput",
"advanced": false,
"display_name": "Text",
"dynamic": false,
@ -599,16 +566,13 @@
],
"list": false,
"list_add_label": "Add More",
"load_from_db": false,
"name": "input_value",
"placeholder": "",
"required": true,
"show": true,
"title_case": false,
"tool_mode": false,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"type": "other",
"value": ""
},
"sender": {
@ -1077,7 +1041,7 @@
"dragging": false,
"id": "TavilySearchComponent-K4joL",
"measured": {
"height": 437,
"height": 435,
"width": 320
},
"position": {
@ -1099,14 +1063,15 @@
"beta": false,
"conditional_paths": [],
"custom_fields": {},
"description": "Uses AgentQL API to extract structured data from a given URL.",
"display_name": "AgentQL Query Data",
"description": "Extracts structured data from a web page using an AgentQL query or a Natural Language description.",
"display_name": "Extract Web Data",
"documentation": "https://docs.agentql.com/rest-api/api-reference",
"edited": false,
"field_order": [
"api_key",
"url",
"query",
"prompt",
"timeout",
"params"
],
@ -1139,9 +1104,9 @@
"api_key": {
"_input_type": "SecretStrInput",
"advanced": false,
"display_name": "AgentQL API Key",
"display_name": "API Key",
"dynamic": false,
"info": "Your AgentQL API key. Get one at https://dev.agentql.com.",
"info": "Your AgentQL API key from dev.agentql.com",
"input_types": [
"Message"
],
@ -1171,7 +1136,7 @@
"show": true,
"title_case": false,
"type": "code",
"value": "import httpx\nfrom loguru import logger\n\nfrom langflow.custom import Component\nfrom langflow.io import (\n DictInput,\n IntInput,\n MessageTextInput,\n MultilineInput,\n Output,\n SecretStrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AgentQL(Component):\n display_name = \"AgentQL Query Data\"\n description = \"Uses AgentQL API to extract structured data from a given URL.\"\n documentation: str = \"https://docs.agentql.com/rest-api/api-reference\"\n icon = \"AgentQL\"\n name = \"AgentQL\"\n\n inputs = [\n SecretStrInput(\n name=\"api_key\",\n display_name=\"AgentQL API Key\",\n required=True,\n password=True,\n info=\"Your AgentQL API key. Get one at https://dev.agentql.com.\",\n ),\n MessageTextInput(\n name=\"url\",\n display_name=\"URL\",\n required=True,\n info=\"The public URL of the webpage to extract data from.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"query\",\n display_name=\"AgentQL Query\",\n required=True,\n info=\"The AgentQL query to execute. Read more at https://docs.agentql.com/agentql-query.\",\n tool_mode=True,\n ),\n IntInput(\n name=\"timeout\",\n display_name=\"Timeout\",\n info=\"Timeout in seconds for the request. Increase if data extraction takes too long.\",\n value=900,\n advanced=True,\n ),\n DictInput(\n name=\"params\",\n display_name=\"Additional Params\",\n info=\"The additional params to send with the request. For details refer to https://docs.agentql.com/rest-api/api-reference#request-body.\",\n is_list=True,\n value={\n \"mode\": \"fast\",\n \"wait_for\": 0,\n \"is_scroll_to_bottom_enabled\": False,\n \"is_screenshot_enabled\": False,\n },\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"build_output\"),\n ]\n\n def build_output(self) -> Data:\n endpoint = \"https://api.agentql.com/v1/query-data\"\n headers = {\n \"X-API-Key\": self.api_key,\n \"Content-Type\": \"application/json\",\n \"X-TF-Request-Origin\": \"langflow\",\n }\n\n payload = {\n \"url\": self.url,\n \"query\": self.query,\n \"params\": self.params,\n }\n\n try:\n response = httpx.post(endpoint, headers=headers, json=payload, timeout=self.timeout)\n response.raise_for_status()\n\n json = response.json()\n data = Data(result=json[\"data\"], metadata=json[\"metadata\"])\n\n except httpx.HTTPStatusError as e:\n response = e.response\n if response.status_code in {401, 403}:\n self.status = \"Please, provide a valid API Key. You can create one at https://dev.agentql.com.\"\n else:\n try:\n error_json = response.json()\n logger.error(\n f\"Failure response: '{response.status_code} {response.reason_phrase}' with body: {error_json}\"\n )\n msg = error_json[\"error_info\"] if \"error_info\" in error_json else error_json[\"detail\"]\n except (ValueError, TypeError):\n msg = f\"HTTP {e}.\"\n self.status = msg\n raise ValueError(self.status) from e\n\n else:\n self.status = data\n return data\n"
"value": "import httpx\nfrom loguru import logger\n\nfrom langflow.custom import Component\nfrom langflow.io import (\n DictInput,\n IntInput,\n MessageTextInput,\n MultilineInput,\n Output,\n SecretStrInput,\n)\nfrom langflow.schema import Data\n\n\nclass AgentQL(Component):\n display_name = \"Extract Web Data\"\n description = \"Extracts structured data from a web page using an AgentQL query or a Natural Language description.\"\n documentation: str = \"https://docs.agentql.com/rest-api/api-reference\"\n icon = \"AgentQL\"\n name = \"AgentQL\"\n\n inputs = [\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n required=True,\n password=True,\n info=\"Your AgentQL API key from dev.agentql.com\",\n ),\n MessageTextInput(\n name=\"url\",\n display_name=\"URL\",\n required=True,\n info=\"The URL of the public web page you want to extract data from.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"query\",\n display_name=\"AgentQL Query\",\n required=False,\n info=\"The AgentQL query to execute. Learn more at https://docs.agentql.com/agentql-query or use a prompt.\",\n tool_mode=True,\n ),\n MultilineInput(\n name=\"prompt\",\n display_name=\"Prompt\",\n required=False,\n info=\"A Natural Language description of the data to extract from the page. Alternative to AgentQL query.\",\n tool_mode=True,\n ),\n IntInput(\n name=\"timeout\",\n display_name=\"Timeout\",\n info=\"Timeout in seconds for the request. Increase if data extraction takes too long.\",\n value=900,\n advanced=True,\n ),\n DictInput(\n name=\"params\",\n display_name=\"Additional Params\",\n info=\"The additional params to send with the request. For details refer to https://docs.agentql.com/rest-api/api-reference#request-body.\",\n is_list=True,\n value={\n \"mode\": \"fast\",\n \"wait_for\": 0,\n \"is_scroll_to_bottom_enabled\": False,\n \"is_screenshot_enabled\": False,\n },\n advanced=True,\n ),\n ]\n\n outputs = [\n Output(display_name=\"Data\", name=\"data\", method=\"build_output\"),\n ]\n\n def build_output(self) -> Data:\n endpoint = \"https://api.agentql.com/v1/query-data\"\n headers = {\n \"X-API-Key\": self.api_key,\n \"Content-Type\": \"application/json\",\n \"X-TF-Request-Origin\": \"langflow\",\n }\n\n payload = {\n \"url\": self.url,\n \"query\": self.query,\n \"prompt\": self.prompt,\n \"params\": self.params,\n }\n\n if not self.prompt and not self.query:\n self.status = \"Either Query or Prompt must be provided.\"\n raise ValueError(self.status)\n if self.prompt and self.query:\n self.status = \"Both Query and Prompt can't be provided at the same time.\"\n raise ValueError(self.status)\n\n try:\n response = httpx.post(endpoint, headers=headers, json=payload, timeout=self.timeout)\n response.raise_for_status()\n\n json = response.json()\n data = Data(result=json[\"data\"], metadata=json[\"metadata\"])\n\n except httpx.HTTPStatusError as e:\n response = e.response\n if response.status_code in {401, 403}:\n self.status = \"Please, provide a valid API Key. You can create one at https://dev.agentql.com.\"\n else:\n try:\n error_json = response.json()\n logger.error(\n f\"Failure response: '{response.status_code} {response.reason_phrase}' with body: {error_json}\"\n )\n msg = error_json[\"error_info\"] if \"error_info\" in error_json else error_json[\"detail\"]\n except (ValueError, TypeError):\n msg = f\"HTTP {e}.\"\n self.status = msg\n raise ValueError(self.status) from e\n\n else:\n self.status = data\n return data\n"
},
"params": {
"_input_type": "DictInput",
@ -1196,12 +1161,36 @@
"wait_for": 0
}
},
"prompt": {
"_input_type": "MultilineInput",
"advanced": false,
"display_name": "Prompt",
"dynamic": false,
"info": "A Natural Language description of the data to extract from the page. Alternative to AgentQL query.",
"input_types": [
"Message"
],
"list": false,
"list_add_label": "Add More",
"load_from_db": false,
"multiline": true,
"name": "prompt",
"placeholder": "",
"required": false,
"show": true,
"title_case": false,
"tool_mode": true,
"trace_as_input": true,
"trace_as_metadata": true,
"type": "str",
"value": ""
},
"query": {
"_input_type": "MultilineInput",
"advanced": false,
"display_name": "AgentQL Query",
"dynamic": false,
"info": "The AgentQL query to execute. Read more at https://docs.agentql.com/agentql-query.",
"info": "The AgentQL query to execute. Learn more at https://docs.agentql.com/agentql-query or use a prompt.",
"input_types": [
"Message"
],
@ -1211,7 +1200,7 @@
"multiline": true,
"name": "query",
"placeholder": "",
"required": true,
"required": false,
"show": true,
"title_case": false,
"tool_mode": true,
@ -1321,7 +1310,7 @@
"type": "table",
"value": [
{
"description": "build_output(api_key: Message, query: Message, url: Message) - Uses AgentQL API to extract structured data from a given URL.",
"description": "build_output(api_key: Message, url: Message) - Extracts structured data from a web page using an AgentQL query or a Natural Language description.",
"name": "AgentQL-build_output",
"tags": [
"AgentQL-build_output"
@ -1334,7 +1323,7 @@
"advanced": false,
"display_name": "URL",
"dynamic": false,
"info": "The public URL of the webpage to extract data from.",
"info": "The URL of the public web page you want to extract data from.",
"input_types": [
"Message"
],
@ -1361,12 +1350,12 @@
"dragging": false,
"id": "AgentQL-R0YLG",
"measured": {
"height": 499,
"height": 599,
"width": 320
},
"position": {
"x": 329.8776020848543,
"y": -114.65601128197832
"x": 258.9873392343597,
"y": -351.3788533005941
},
"selected": false,
"type": "genericNode"
@ -1379,7 +1368,6 @@
"Message"
],
"beta": false,
"category": "agents",
"conditional_paths": [],
"custom_fields": {},
"description": "Define the agent's instructions, then enter a task to complete using tools.",
@ -1396,6 +1384,8 @@
"api_key",
"temperature",
"seed",
"max_retries",
"timeout",
"system_prompt",
"tools",
"input_value",
@ -1414,9 +1404,7 @@
],
"frozen": false,
"icon": "bot",
"key": "Agent",
"legacy": false,
"lf_version": "1.2.0",
"metadata": {},
"minimized": false,
"output_types": [],
@ -1436,7 +1424,6 @@
}
],
"pinned": false,
"score": 1.1732828199964098e-19,
"template": {
"_type": "Component",
"add_current_date_tool": {
@ -1502,7 +1489,35 @@
"SambaNova",
"Custom"
],
"options_metadata": [],
"options_metadata": [
{
"icon": "Amazon"
},
{
"icon": "Anthropic"
},
{
"icon": "Azure"
},
{
"icon": "GoogleGenerativeAI"
},
{
"icon": "Groq"
},
{
"icon": "NVIDIA"
},
{
"icon": "OpenAI"
},
{
"icon": "SambaNova"
},
{
"icon": "brain"
}
],
"placeholder": "",
"real_time_refresh": true,
"required": false,
@ -1921,7 +1936,7 @@
"name": "temperature",
"placeholder": "",
"range_spec": {
"max": 2,
"max": 1,
"min": 0,
"step": 0.01,
"step_type": "float"
@ -2025,7 +2040,7 @@
"dragging": false,
"id": "Agent-7PMCu",
"measured": {
"height": 624,
"height": 621,
"width": 320
},
"position": {
@ -2146,18 +2161,18 @@
}
],
"viewport": {
"x": 636.4185821740807,
"y": 225.96076866418508,
"zoom": 1.0499010256781385
"x": 546.0173634466885,
"y": 279.0139837091223,
"zoom": 0.671291450402032
}
},
"description": "Searches and compares product prices across multiple e-commerce platforms. ",
"endpoint_name": null,
"icon": "DollarSign",
"id": "675468b8-08ab-44b0-aef1-87d76a75570a",
"is_component": false,
"last_tested_version": "1.2.0",
"name": "Price Deal Finder",
"icon": "DollarSign",
"tags": [
"web-scraping",
"agents"