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
This commit is contained in:
Debanjum Singh Solanky 2024-03-31 18:05:22 +05:30
parent ad4fa4b2f4
commit 29c1c18042
4 changed files with 5 additions and 9 deletions

View file

@ -475,7 +475,7 @@ async def chat(
common: CommonQueryParams, common: CommonQueryParams,
q: str, q: str,
n: Optional[int] = 5, n: Optional[int] = 5,
d: Optional[float] = 0.18, d: Optional[float] = 0.22,
stream: Optional[bool] = False, stream: Optional[bool] = False,
title: Optional[str] = None, title: Optional[str] = None,
conversation_id: Optional[int] = None, conversation_id: Optional[int] = None,

View file

@ -335,7 +335,7 @@ def test_notes_search(client, search_config: SearchConfig, sample_org_data, defa
user_query = quote("How to git install application?") user_query = quote("How to git install application?")
# Act # 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
assert response.status_code == 200 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?") user_query = quote("How to find my goat?")
# Act # 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
assert response.status_code == 200 assert response.status_code == 200
@ -438,7 +438,7 @@ def test_notes_search_requires_parent_context(
user_query = quote("Install Khoj on Emacs") user_query = quote("Install Khoj on Emacs")
# Act # 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
assert response.status_code == 200 assert response.status_code == 200

View file

@ -56,7 +56,7 @@ def test_index_update_with_user2_inaccessible_user1(client, api_user2: KhojApiUs
# Assert # Assert
assert update_response.status_code == 200 assert update_response.status_code == 200
assert len(results) == 5 assert len(results) == 3
for result in results: for result in results:
assert result["additional"]["file"] not in source_file_symbol assert result["additional"]["file"] not in source_file_symbol

View file

@ -470,10 +470,6 @@ async def test_websearch_with_operators(chat_client):
["site:reddit.com" in response for response in responses] ["site:reddit.com" in response for response in responses]
), "Expected a search query to include site:reddit.com but got: " + str(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 @pytest.mark.anyio