Skip to content

Update AgentQL's tool name #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 14 additions & 14 deletions agentstack/_tools/agentql/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

API_KEY = os.getenv("AGENTQL_API_KEY")

def query_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:

def extract_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
"""
url: url of website to scrape
query: described below
Expand Down Expand Up @@ -44,37 +45,36 @@ def query_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
}
```
"""
payload = {
"url": url,
"query": query,
"prompt": prompt
}
payload = {"url": url, "query": query, "prompt": prompt}

headers = {
"X-API-Key": f"{API_KEY}",
"Content-Type": "application/json"
}
headers = {"X-API-Key": f"{API_KEY}", "Content-Type": "application/json"}

try:
response = httpx.post(
QUERY_DATA_ENDPOINT,
headers=headers,
json=payload,
timeout=API_TIMEOUT_SECONDS
timeout=API_TIMEOUT_SECONDS,
)
response.raise_for_status()

except httpx.HTTPStatusError as e:
response = e.response
if response.status_code in [401, 403]:
raise ValueError("Please, provide a valid API Key. You can create one at https://dev.agentql.com.") from e
raise ValueError(
"Please, provide a valid API Key. You can create one at https://dev.agentql.com."
) from e
else:
try:
error_json = response.json()
msg = error_json["error_info"] if "error_info" in error_json else error_json["detail"]
msg = (
error_json["error_info"]
if "error_info" in error_json
else error_json["detail"]
)
except (ValueError, TypeError):
msg = f"HTTP {e}."
raise ValueError(msg) from e
else:
json = response.json()
return json["data"]
return json["data"]
2 changes: 1 addition & 1 deletion agentstack/_tools/agentql/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"env": {
"AGENTQL_API_KEY": "..."
},
"tools": ["query_data"],
"tools": ["extract_data"],
"cta": "Create your AgentQL API key at https://dev.agentql.com"
}
Loading