From 29c1c180429fea515fb8654edf1befdc7e6905db Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 31 Mar 2024 18:05:22 +0530 Subject: [PATCH] Increase search distance to get relevant content for chat post indexer update More content indexed per entry would result in an overall scores lowering effect. Increase default search distance threshold to counter that - Details - Fix expected results post indexing updates - Fix search with max distance post indexing updates - Minor - Remove openai chat actor test for after: operator as it's not expected anymore --- src/khoj/routers/api_chat.py | 2 +- tests/test_client.py | 6 +++--- tests/test_multiple_users.py | 2 +- tests/test_openai_chat_actors.py | 4 ---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py index 9336fd6f..5ded7bff 100644 --- a/src/khoj/routers/api_chat.py +++ b/src/khoj/routers/api_chat.py @@ -475,7 +475,7 @@ async def chat( common: CommonQueryParams, q: str, n: Optional[int] = 5, - d: Optional[float] = 0.18, + d: Optional[float] = 0.22, stream: Optional[bool] = False, title: Optional[str] = None, conversation_id: Optional[int] = None, diff --git a/tests/test_client.py b/tests/test_client.py index abbd1fec..3cd2eee4 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -335,7 +335,7 @@ def test_notes_search(client, search_config: SearchConfig, sample_org_data, defa user_query = quote("How to git install application?") # Act - response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.18", headers=headers) + response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.22", headers=headers) # Assert assert response.status_code == 200 @@ -354,7 +354,7 @@ def test_notes_search_no_results(client, search_config: SearchConfig, sample_org user_query = quote("How to find my goat?") # Act - response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.18", headers=headers) + response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.22", headers=headers) # Assert assert response.status_code == 200 @@ -438,7 +438,7 @@ def test_notes_search_requires_parent_context( user_query = quote("Install Khoj on Emacs") # Act - response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.18", headers=headers) + response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true&max_distance=0.22", headers=headers) # Assert assert response.status_code == 200 diff --git a/tests/test_multiple_users.py b/tests/test_multiple_users.py index bb0f99d8..4e8e456a 100644 --- a/tests/test_multiple_users.py +++ b/tests/test_multiple_users.py @@ -56,7 +56,7 @@ def test_index_update_with_user2_inaccessible_user1(client, api_user2: KhojApiUs # Assert assert update_response.status_code == 200 - assert len(results) == 5 + assert len(results) == 3 for result in results: assert result["additional"]["file"] not in source_file_symbol diff --git a/tests/test_openai_chat_actors.py b/tests/test_openai_chat_actors.py index 5c2855b2..df9d8f07 100644 --- a/tests/test_openai_chat_actors.py +++ b/tests/test_openai_chat_actors.py @@ -470,10 +470,6 @@ async def test_websearch_with_operators(chat_client): ["site:reddit.com" in response for response in responses] ), "Expected a search query to include site:reddit.com but got: " + str(responses) - assert any( - ["after:2024/04/01" in response for response in responses] - ), "Expected a search query to include after:2024/04/01 but got: " + str(responses) - # ---------------------------------------------------------------------------------------------------- @pytest.mark.anyio