Skip to content

Commit 30885d0

Browse files
author
Baur
authored
Merge pull request #40 from ZenGuard-AI/baur/branch
[bug] change post to get for report function
2 parents e0093c5 + f8f92e3 commit 30885d0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "zenguard"
3-
version = "0.1.16"
3+
version = "0.1.18"
44
description = "Fast production grade security for GenAI applications"
55
authors = ["ZenGuard Team <hello@zenguard.ai>"]
66
license = "MIT"

tests/zenguard_e2e_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_detect_error_no_detectors(zenguard):
111111

112112

113113
def test_report_with_valid_detector_and_days(zenguard):
114-
with patch("httpx.post") as mock_post:
114+
with patch("httpx.get") as mock_post:
115115
mock_response = Mock()
116116
# TODO(baur): Update this to the actual response
117117
mock_response.json.return_value = {"prompt_injections": 10}
@@ -124,7 +124,7 @@ def test_report_with_valid_detector_and_days(zenguard):
124124

125125
# Assert only the relevant parts of the API call
126126
assert API_REPORT_PROMPT_INJECTIONS in mock_post_args[0]
127-
assert mock_post_kwargs["json"] == {"days": 7}
127+
assert mock_post_kwargs["params"] == {"days": 7}
128128

129129

130130
def test_report_with_invalid_detector(zenguard):
@@ -133,7 +133,7 @@ def test_report_with_invalid_detector(zenguard):
133133

134134

135135
def test_report_with_request_error(zenguard):
136-
with patch("httpx.post") as mock_post:
136+
with patch("httpx.get") as mock_post:
137137
mock_post.side_effect = httpx.RequestError("Connection error")
138138

139139
with pytest.raises(RuntimeError) as exc_info:

zenguard/zenguard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,16 @@ def report(self, detector: Detector, days: int = None):
222222
"Only Prompt Injection detector is currently supported for reports"
223223
)
224224

225-
json = {}
225+
params = {}
226226
if days:
227-
json = {"days": days}
227+
params["days"] = days
228228

229229
url = self._backend + API_REPORT_PROMPT_INJECTIONS
230230

231231
try:
232-
response = httpx.post(
232+
response = httpx.get(
233233
url,
234-
json=json,
234+
params=params,
235235
headers={"x-api-key": self._api_key},
236236
timeout=20,
237237
)

0 commit comments

Comments
 (0)