Skip to content

Commit 04e62b7

Browse files
authored
Merge pull request #339 from desi003/update-agentql-tool-name
Update AgentQL's tool name
2 parents 8cb98ab + c7cfb9b commit 04e62b7

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

agentstack/_tools/agentql/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
API_KEY = os.getenv("AGENTQL_API_KEY")
1010

11-
def query_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
11+
12+
def extract_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
1213
"""
1314
url: url of website to scrape
1415
query: described below
@@ -44,37 +45,36 @@ def query_data(url: str, query: Optional[str], prompt: Optional[str]) -> dict:
4445
}
4546
```
4647
"""
47-
payload = {
48-
"url": url,
49-
"query": query,
50-
"prompt": prompt
51-
}
48+
payload = {"url": url, "query": query, "prompt": prompt}
5249

53-
headers = {
54-
"X-API-Key": f"{API_KEY}",
55-
"Content-Type": "application/json"
56-
}
50+
headers = {"X-API-Key": f"{API_KEY}", "Content-Type": "application/json"}
5751

5852
try:
5953
response = httpx.post(
6054
QUERY_DATA_ENDPOINT,
6155
headers=headers,
6256
json=payload,
63-
timeout=API_TIMEOUT_SECONDS
57+
timeout=API_TIMEOUT_SECONDS,
6458
)
6559
response.raise_for_status()
6660

6761
except httpx.HTTPStatusError as e:
6862
response = e.response
6963
if response.status_code in [401, 403]:
70-
raise ValueError("Please, provide a valid API Key. You can create one at https://dev.agentql.com.") from e
64+
raise ValueError(
65+
"Please, provide a valid API Key. You can create one at https://dev.agentql.com."
66+
) from e
7167
else:
7268
try:
7369
error_json = response.json()
74-
msg = error_json["error_info"] if "error_info" in error_json else error_json["detail"]
70+
msg = (
71+
error_json["error_info"]
72+
if "error_info" in error_json
73+
else error_json["detail"]
74+
)
7575
except (ValueError, TypeError):
7676
msg = f"HTTP {e}."
7777
raise ValueError(msg) from e
7878
else:
7979
json = response.json()
80-
return json["data"]
80+
return json["data"]

agentstack/_tools/agentql/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"env": {
77
"AGENTQL_API_KEY": "..."
88
},
9-
"tools": ["query_data"],
9+
"tools": ["extract_data"],
1010
"cta": "Create your AgentQL API key at https://dev.agentql.com"
1111
}

0 commit comments

Comments
 (0)