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

aaq urgency check endpoint V2 #616

Merged
merged 9 commits into from
Aug 12, 2024
Merged

aaq urgency check endpoint V2 #616

merged 9 commits into from
Aug 12, 2024

Conversation

Hlamallama
Copy link
Contributor

@Hlamallama Hlamallama commented Aug 6, 2024

Search endpoint to call aaq seatch and urgency detect

Copy link
Contributor

@erikh360 erikh360 left a 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"]
Copy link
Contributor

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"]}
Copy link
Contributor

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)

@responses.activate
def test_urgency_check_urgent(self):
"""
Test that we can get an urgency score of 1.0
Copy link
Contributor

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

user = get_user_model().objects.create_user("test")
self.client.force_authenticate(user)
fakeAaqUdV2Api = FakeAaqUdV2Api()
responses.add_callback(
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

content_type="application/json",
)

payload = json.dumps({"message_text": "I am pregnant and out of breath"})
Copy link
Contributor

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

Copy link
Contributor

@erikh360 erikh360 left a 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
Comment on lines 182 to 188
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"]

Copy link
Contributor

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?

Copy link
Contributor

@erikh360 erikh360 left a 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
Comment on lines 72 to 76
urgency_check_payload = {
"message_text": query_text,
}

check_urgency_response = check_urgency_v2(urgency_check_payload)
Copy link
Contributor

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

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

@Hlamallama Hlamallama merged commit 5ef6da2 into develop Aug 12, 2024
1 check passed
@Hlamallama Hlamallama deleted the aaq-v2-check-urgency branch August 12, 2024 06:42
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