Skip to content

Commit

Permalink
start search results from 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlamallama committed Sep 5, 2024
1 parent f9af311 commit 4890d44
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions aaq/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def post_search(self, request):
"llm_response": None,
"query_id": 1,
"search_results": {
"0": {
"1": {
"distance": 0.1,
"id": 23,
"text": "Example content text",
"title": "Example content title",
},
"1": {
"2": {
"distance": 0.2,
"id": 12,
"text": "Another example content text",
Expand Down Expand Up @@ -124,8 +124,8 @@ class FakeAaqUdV2Api:
def post_urgency_detect_return_true(self, request):
resp_body = {
"details": {
"0": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"1": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
"1": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"2": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
},
"is_urgent": True,
"matched_rules": [
Expand Down
16 changes: 8 additions & 8 deletions aaq/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ def test_search_function(self):
self.assertEqual(json.loads(search_request.request.body), payload)
self.assertIn("Bearer", search_request.request.headers["Authorization"])
assert response == {
"message": "*0* - Example content title\n"
"*1* - Another example content title",
"message": "*1* - Example content title\n"
"*2* - Another example content title",
"body": {
"0": {"text": "Example content text", "id": 23},
"1": {"text": "Another example content text", "id": 12},
1: {"text": "Example content text", "id": 23},
2: {"text": "Another example content text", "id": 12},
},
"feedback_secret_key": "secret-key-12345-abcde",
"query_id": 1,
"details": {
"0": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"1": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
"1": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"2": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
},
"is_urgent": True,
"matched_rules": [
Expand Down Expand Up @@ -101,8 +101,8 @@ def test_urgency_check(self):

assert response == {
"details": {
"0": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"1": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
"1": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"2": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
},
"is_urgent": True,
"matched_rules": [
Expand Down
12 changes: 6 additions & 6 deletions aaq/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,17 @@ def test_search(self):
self.assertIn("matched_rules", response.json())

assert response.json() == {
"message": "*0* - Example content title\n"
"*1* - Another example content title",
"message": "*1* - Example content title\n"
"*2* - Another example content title",
"body": {
"0": {"text": "Example content text", "id": 23},
"1": {"text": "Another example content text", "id": 12},
"1": {"text": "Example content text", "id": 23},
"2": {"text": "Another example content text", "id": 12},
},
"feedback_secret_key": "secret-key-12345-abcde",
"query_id": 1,
"details": {
"0": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"1": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
"1": {"distance": 0.1, "urgency_rule": "Blurry vision and dizziness"},
"2": {"distance": 0.2, "urgency_rule": "Nausea that lasts for 3 days"},
},
"is_urgent": True,
"matched_rules": [
Expand Down
2 changes: 1 addition & 1 deletion aaq/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def search(query_text, generate_llm_response, query_metadata):
body_content = {}
message_titles = []

for key, value in search_results.items():
for key, value in enumerate(search_results.values(), start=1):
text = value["text"]
id = value["id"]
title = value["title"]
Expand Down

0 comments on commit 4890d44

Please sign in to comment.