-
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
aaq urgency check endpoint V2 #616
Conversation
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.
Looking at the return body we could just return that straight to the flow.
aaq/views.py
Outdated
} | ||
|
||
response = requests.request("POST", url, json=message_text, headers=headers) | ||
is_urgent = response.json()["is_urgent"] |
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 think we should also return true/false to the rp flow, then there is no guessing what 0/1 means.
aaq/views.py
Outdated
} | ||
|
||
response = requests.request("POST", url, json=message_text, headers=headers) | ||
is_urgent = {"is_urgent": response.json()["is_urgent"]} |
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.
We could just change this to:
return Response(response.json(), status=status.HTTP_200_OK)
aaq/tests/test_views.py
Outdated
@responses.activate | ||
def test_urgency_check_urgent(self): | ||
""" | ||
Test that we can get an urgency score of 1.0 |
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.
Update these docstrings to match the true/false
aaq/tests/test_views.py
Outdated
user = get_user_model().objects.create_user("test") | ||
self.client.force_authenticate(user) | ||
fakeAaqUdV2Api = FakeAaqUdV2Api() | ||
responses.add_callback( |
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.
Can you validate the request payload that is sent to the AAQ endpoint please?
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 have this test test_urgency_check_invalid to check if the payload is valid
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.
That is the payload to our endpoint, I'm talking about the payload e send to the aaq endpoint
aaq/tests/test_views.py
Outdated
content_type="application/json", | ||
) | ||
|
||
payload = json.dumps({"message_text": "I am pregnant and out of breath"}) |
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 you remove the .dumps here, you can remove the 2 .loads() calls on line 571
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.
Just the one comment for now.
Can we maybe move some of this functionality into a utils.py file to separate things a bit. Lets chat in slack about this
aaq/views.py
Outdated
if "generate_llm_response" in serializer.validated_data: | ||
search_payload["generate_llm_response"] = serializer.validated_data[ | ||
"generate_llm_response" | ||
] | ||
if "query_metadata" in serializer.validated_data: | ||
search_payload["query_metadata"] = serializer.validated_data["query_metadata"] | ||
|
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.
Can we give these defaults in the serializer and always include them?
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.
Starting to look good, just a few comments
aaq/utils.py
Outdated
urgency_check_payload = { | ||
"message_text": query_text, | ||
} | ||
|
||
check_urgency_response = check_urgency_v2(urgency_check_payload) |
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.
Do you need to send a dict here? You build a dict inside check_urgency_v2
too?
If the tests are passing it means somewhere we're not checking something
aaq/utils.py
Outdated
|
||
check_urgency_response = check_urgency_v2(urgency_check_payload) | ||
|
||
json_msg.update(check_urgency_response.data) |
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.
Can we use .json() instead of .data? Probably applies to a few places
Search endpoint to call aaq seatch and urgency detect