feat: Update AgentQL integration with new features (#7089)
* feat: Update AgentQL integration with new features * Update templates * [autofix.ci] apply automated fixes --------- 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:
parent
37bc0467b6
commit
2dfdb9f701
3 changed files with 355 additions and 127 deletions
|
|
@ -2,8 +2,10 @@ import httpx
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from langflow.custom import Component
|
from langflow.custom import Component
|
||||||
|
from langflow.field_typing.range_spec import RangeSpec
|
||||||
from langflow.io import (
|
from langflow.io import (
|
||||||
DictInput,
|
BoolInput,
|
||||||
|
DropdownInput,
|
||||||
IntInput,
|
IntInput,
|
||||||
MessageTextInput,
|
MessageTextInput,
|
||||||
MultilineInput,
|
MultilineInput,
|
||||||
|
|
@ -49,24 +51,48 @@ class AgentQL(Component):
|
||||||
info="A Natural Language description of the data to extract from the page. Alternative to AgentQL query.",
|
info="A Natural Language description of the data to extract from the page. Alternative to AgentQL query.",
|
||||||
tool_mode=True,
|
tool_mode=True,
|
||||||
),
|
),
|
||||||
|
BoolInput(
|
||||||
|
name="is_stealth_mode_enabled",
|
||||||
|
display_name="Enable Stealth Mode (Beta)",
|
||||||
|
info="Enable experimental anti-bot evasion strategies. May not work for all websites at all times.",
|
||||||
|
value=False,
|
||||||
|
advanced=True,
|
||||||
|
),
|
||||||
IntInput(
|
IntInput(
|
||||||
name="timeout",
|
name="timeout",
|
||||||
display_name="Timeout",
|
display_name="Timeout",
|
||||||
info="Timeout in seconds for the request. Increase if data extraction takes too long.",
|
info="Seconds to wait for a request.",
|
||||||
value=900,
|
value=900,
|
||||||
advanced=True,
|
advanced=True,
|
||||||
),
|
),
|
||||||
DictInput(
|
DropdownInput(
|
||||||
name="params",
|
name="mode",
|
||||||
display_name="Additional Params",
|
display_name="Request Mode",
|
||||||
info="The additional params to send with the request. For details refer to https://docs.agentql.com/rest-api/api-reference#request-body.",
|
info="'standard' uses deep data analysis, while 'fast' trades some depth of analysis for speed.",
|
||||||
is_list=True,
|
options=["fast", "standard"],
|
||||||
value={
|
value="fast",
|
||||||
"mode": "fast",
|
advanced=True,
|
||||||
"wait_for": 0,
|
),
|
||||||
"is_scroll_to_bottom_enabled": False,
|
IntInput(
|
||||||
"is_screenshot_enabled": False,
|
name="wait_for",
|
||||||
},
|
display_name="Wait For",
|
||||||
|
info="Seconds to wait for the page to load before extracting data.",
|
||||||
|
value=0,
|
||||||
|
range_spec=RangeSpec(min=0, max=10, step_type="int"),
|
||||||
|
advanced=True,
|
||||||
|
),
|
||||||
|
BoolInput(
|
||||||
|
name="is_scroll_to_bottom_enabled",
|
||||||
|
display_name="Enable scroll to bottom",
|
||||||
|
info="Scroll to bottom of the page before extracting data.",
|
||||||
|
value=False,
|
||||||
|
advanced=True,
|
||||||
|
),
|
||||||
|
BoolInput(
|
||||||
|
name="is_screenshot_enabled",
|
||||||
|
display_name="Enable screenshot",
|
||||||
|
info="Take a screenshot before extracting data. Returned in 'metadata' as a Base64 string.",
|
||||||
|
value=False,
|
||||||
advanced=True,
|
advanced=True,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
@ -87,7 +113,15 @@ class AgentQL(Component):
|
||||||
"url": self.url,
|
"url": self.url,
|
||||||
"query": self.query,
|
"query": self.query,
|
||||||
"prompt": self.prompt,
|
"prompt": self.prompt,
|
||||||
"params": self.params,
|
"params": {
|
||||||
|
"mode": self.mode,
|
||||||
|
"wait_for": self.wait_for,
|
||||||
|
"is_scroll_to_bottom_enabled": self.is_scroll_to_bottom_enabled,
|
||||||
|
"is_screenshot_enabled": self.is_screenshot_enabled,
|
||||||
|
},
|
||||||
|
"metadata": {
|
||||||
|
"experimental_stealth_mode_enabled": self.is_stealth_mode_enabled,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if not self.prompt and not self.query:
|
if not self.prompt and not self.query:
|
||||||
|
|
@ -106,7 +140,7 @@ class AgentQL(Component):
|
||||||
|
|
||||||
except httpx.HTTPStatusError as e:
|
except httpx.HTTPStatusError as e:
|
||||||
response = e.response
|
response = e.response
|
||||||
if response.status_code in {401, 403}:
|
if response.status_code == httpx.codes.UNAUTHORIZED:
|
||||||
self.status = "Please, provide a valid API Key. You can create one at https://dev.agentql.com."
|
self.status = "Please, provide a valid API Key. You can create one at https://dev.agentql.com."
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue