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

Conversation

Hlamallama
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Oct 22, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  aaq
  utils.py
  aaq/tests
  helpers.py
Project Total  

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():
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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():
Copy link
Contributor

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

Copy link
Contributor

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

@Hlamallama Hlamallama merged commit b9cf776 into develop Oct 22, 2024
2 checks passed
@Hlamallama Hlamallama deleted the update-gobberish-detection-function branch October 22, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants