From 4890d440e9d0f247259ef64808dd3882b0fa74cd Mon Sep 17 00:00:00 2001 From: Hlamalani Date: Thu, 5 Sep 2024 12:02:30 +0200 Subject: [PATCH] start search results from 1 --- aaq/tests/helpers.py | 8 ++++---- aaq/tests/test_utils.py | 16 ++++++++-------- aaq/tests/test_views.py | 12 ++++++------ aaq/utils.py | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/aaq/tests/helpers.py b/aaq/tests/helpers.py index 4bdb9256..cde07299 100644 --- a/aaq/tests/helpers.py +++ b/aaq/tests/helpers.py @@ -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", @@ -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": [ diff --git a/aaq/tests/test_utils.py b/aaq/tests/test_utils.py index 426ee7f9..9390c87a 100644 --- a/aaq/tests/test_utils.py +++ b/aaq/tests/test_utils.py @@ -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": [ @@ -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": [ diff --git a/aaq/tests/test_views.py b/aaq/tests/test_views.py index b533b2f5..1d9b1999 100644 --- a/aaq/tests/test_views.py +++ b/aaq/tests/test_views.py @@ -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": [ diff --git a/aaq/utils.py b/aaq/utils.py index 9739c62f..017c8ae5 100644 --- a/aaq/utils.py +++ b/aaq/utils.py @@ -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"]