From eb13894aa46d44a581d261bef4ef139340a96211 Mon Sep 17 00:00:00 2001 From: Hamada Salhab Date: Thu, 17 Oct 2024 05:46:07 +0300 Subject: [PATCH] feat(agents-api): Add `alpha` to hybrid search params in system tools execution (#682) > [!IMPORTANT] > Add `alpha` parameter to hybrid search in `execute_system()` with default value 0.75 and adjust `confidence` default to 0.5. > > - **Behavior**: > - Add `alpha` parameter to `HybridDocSearchRequest` in `execute_system()` for hybrid search when both `text` and `vector` are present. > - Default `alpha` value set to 0.75. > - Change default `confidence` value from 0.7 to 0.5 in hybrid search context. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral) for e67b64cf0b843c496f7f451f3c1b5e76a7f626c9. It will automatically update as commits are pushed. --------- Co-authored-by: HamadaSalhab --- agents-api/agents_api/activities/execute_system.py | 3 ++- agents-api/agents_api/models/execution/create_execution.py | 4 +++- agents-api/agents_api/models/execution/get_execution.py | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/agents-api/agents_api/activities/execute_system.py b/agents-api/agents_api/activities/execute_system.py index ae3b9fc17..780d4c0fb 100644 --- a/agents-api/agents_api/activities/execute_system.py +++ b/agents-api/agents_api/activities/execute_system.py @@ -109,7 +109,8 @@ async def execute_system( search_params = HybridDocSearchRequest( text=arguments.pop("text"), vector=arguments.pop("vector"), - confidence=arguments.pop("confidence", 0.7), + alpha=arguments.pop("alpha", 0.75), + confidence=arguments.pop("confidence", 0.5), limit=arguments.get("limit", 10), ) diff --git a/agents-api/agents_api/models/execution/create_execution.py b/agents-api/agents_api/models/execution/create_execution.py index 2b509cda4..832532d6d 100644 --- a/agents-api/agents_api/models/execution/create_execution.py +++ b/agents-api/agents_api/models/execution/create_execution.py @@ -60,7 +60,9 @@ def create_execution( data["metadata"] = data.get("metadata", {}) execution_data = data - if execution_data["output"] is not None and not isinstance(execution_data["output"], dict): + if execution_data["output"] is not None and not isinstance( + execution_data["output"], dict + ): execution_data["output"] = {OUTPUT_UNNEST_KEY: execution_data["output"]} columns, values = cozo_process_mutate_data( diff --git a/agents-api/agents_api/models/execution/get_execution.py b/agents-api/agents_api/models/execution/get_execution.py index 11eb1e107..da76701f4 100644 --- a/agents-api/agents_api/models/execution/get_execution.py +++ b/agents-api/agents_api/models/execution/get_execution.py @@ -32,7 +32,9 @@ one=True, transform=lambda d: { **d, - "output": d["output"][OUTPUT_UNNEST_KEY] if OUTPUT_UNNEST_KEY in d["output"] else d["output"], + "output": d["output"][OUTPUT_UNNEST_KEY] + if OUTPUT_UNNEST_KEY in d["output"] + else d["output"], }, ) @cozo_query