Skip to content
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

update gibberish response dict #643

Merged
merged 7 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
7 changes: 2 additions & 5 deletions aaq/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,9 @@ def post_search(self, request):
return (200, {}, json.dumps(resp_body))

def post_search_return_empty(self, request):
resp_body = {
"status": 400,
"error": {"detail": "Gibberish text detected: vyjhftgdfdgt"},
}
resp_body = {"detail": "Gibberish text detected: vyjhftgdfdgt"}

return (200, {}, json.dumps(resp_body))
return (400, {}, json.dumps(resp_body))


class FakeAaqUdV2Api:
Expand Down
3 changes: 3 additions & 0 deletions aaq/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def test_search_gibberish(self):
query_metadata = {}
response = search(query_text, generate_llm_response, query_metadata)

search_request = responses.calls[0]

assert search_request.response.status_code == 400
assert response.data == {
"message": "Gibberish Detected",
}
4 changes: 2 additions & 2 deletions aaq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def search(query_text, generate_llm_response, query_metadata):

response = requests.request("POST", url, json=payload, headers=headers)

if "error" in response.json():
error_detail = response.json()["error"].get("detail", "")
if response.status_code == status.HTTP_400_BAD_REQUEST and "detail" in response.json():
error_detail = response.json().get("detail", "")
if "Gibberish text detected" in error_detail:
json_msg = {
"message": "Gibberish Detected",
Expand Down
Loading