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

start search results from 1 #626

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading