From edc471d1e2098bd9cdd62033d503431ca9d0a35e Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 29 Oct 2024 00:44:23 +0530 Subject: [PATCH 1/2] Update search_docs_by_embedding.py --- agents-api/agents_api/models/docs/search_docs_by_embedding.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agents-api/agents_api/models/docs/search_docs_by_embedding.py b/agents-api/agents_api/models/docs/search_docs_by_embedding.py index 7f8bdaa61..382238f99 100644 --- a/agents-api/agents_api/models/docs/search_docs_by_embedding.py +++ b/agents-api/agents_api/models/docs/search_docs_by_embedding.py @@ -213,6 +213,8 @@ def search_docs_by_embedding( distance = cos_dist(query, embedding), distance <= {radius} + :limit {k*(3 if mmr_strength else 1)} # Get more candidates for diversity + :create _search_result {{ doc_id, index, @@ -244,7 +246,7 @@ def search_docs_by_embedding( # Sort the results by distance to find the closest matches :sort -mmr_score - :limit {k} + :limit {k*(3 if mmr_strength else 1)}, # Get more candidates for diversity :create _interim {{ owner_type, From 8460571cadaa2f0e03da22f2f5a393cb0e0f1938 Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Tue, 29 Oct 2024 01:21:31 +0530 Subject: [PATCH 2/2] Update search_docs_by_embedding.py --- agents-api/agents_api/models/docs/search_docs_by_embedding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents-api/agents_api/models/docs/search_docs_by_embedding.py b/agents-api/agents_api/models/docs/search_docs_by_embedding.py index 382238f99..382bff069 100644 --- a/agents-api/agents_api/models/docs/search_docs_by_embedding.py +++ b/agents-api/agents_api/models/docs/search_docs_by_embedding.py @@ -246,7 +246,7 @@ def search_docs_by_embedding( # Sort the results by distance to find the closest matches :sort -mmr_score - :limit {k*(3 if mmr_strength else 1)}, # Get more candidates for diversity + :limit {k*(3 if mmr_strength else 1)} # Get more candidates for diversity :create _interim {{ owner_type,