-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
aaq/utils.py
Outdated
@@ -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 "detail" in response.json(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure detail won't be present for any other requests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a successful search response doesn't doesn't have the detail key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, but it might be confusing later on so what about something like:
if response.status_code == 400 "detail" in response.json():
Then theres no doubt that we are handling an error,
You'll need to make sure you mock the status code the same as the AAQ service returns it.
aaq/utils.py
Outdated
@@ -35,13 +35,13 @@ 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 == 400 and "detail" in response.json(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant we should use the status.HTTP_400_BAD_REQUEST
here, if we return 400 to rapidpro it would think the request failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if response.status_code == status.HTTP_400_BAD_REQUEST and "detail" in response.json():
Is what I meant
No description provided.