Skip to content

Commit

Permalink
Merge pull request #40 from ZenGuard-AI/baur/branch
Browse files Browse the repository at this point in the history
[bug] change post to get for report function
  • Loading branch information
baur-krykpayev authored Jun 17, 2024
2 parents e0093c5 + f8f92e3 commit 30885d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zenguard"
version = "0.1.16"
version = "0.1.18"
description = "Fast production grade security for GenAI applications"
authors = ["ZenGuard Team <[email protected]>"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions tests/zenguard_e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_detect_error_no_detectors(zenguard):


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

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


def test_report_with_invalid_detector(zenguard):
Expand All @@ -133,7 +133,7 @@ def test_report_with_invalid_detector(zenguard):


def test_report_with_request_error(zenguard):
with patch("httpx.post") as mock_post:
with patch("httpx.get") as mock_post:
mock_post.side_effect = httpx.RequestError("Connection error")

with pytest.raises(RuntimeError) as exc_info:
Expand Down
8 changes: 4 additions & 4 deletions zenguard/zenguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,16 @@ def report(self, detector: Detector, days: int = None):
"Only Prompt Injection detector is currently supported for reports"
)

json = {}
params = {}
if days:
json = {"days": days}
params["days"] = days

url = self._backend + API_REPORT_PROMPT_INJECTIONS

try:
response = httpx.post(
response = httpx.get(
url,
json=json,
params=params,
headers={"x-api-key": self._api_key},
timeout=20,
)
Expand Down

0 comments on commit 30885d0

Please sign in to comment.