From 001c289e3ce5f3eb321da7d609397f439e6b35fc Mon Sep 17 00:00:00 2001 From: vedantsahai18 Date: Mon, 6 Jan 2025 21:12:55 -0500 Subject: [PATCH 1/2] fix: doc routes fix --- agents-api/agents_api/queries/docs/search_docs_by_embedding.py | 2 +- agents-api/agents_api/queries/docs/search_docs_hybrid.py | 2 +- agents-api/tests/test_docs_routes.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/agents-api/agents_api/queries/docs/search_docs_by_embedding.py b/agents-api/agents_api/queries/docs/search_docs_by_embedding.py index 64dff4c42..9756e205a 100644 --- a/agents-api/agents_api/queries/docs/search_docs_by_embedding.py +++ b/agents-api/agents_api/queries/docs/search_docs_by_embedding.py @@ -36,7 +36,7 @@ async def search_docs_by_embedding( embedding: list[float], k: int = 10, owners: list[tuple[Literal["user", "agent"], UUID]], - confidence: float = 0.5, + confidence: int | float = 0.5, metadata_filter: dict[str, Any] = {}, ) -> tuple[str, list]: """ diff --git a/agents-api/agents_api/queries/docs/search_docs_hybrid.py b/agents-api/agents_api/queries/docs/search_docs_hybrid.py index f17d8201f..db5362057 100644 --- a/agents-api/agents_api/queries/docs/search_docs_hybrid.py +++ b/agents-api/agents_api/queries/docs/search_docs_hybrid.py @@ -46,7 +46,7 @@ async def search_docs_hybrid( alpha: float = 0.5, metadata_filter: dict[str, Any] = {}, search_language: str = "english", - confidence: float = 0.5, + confidence: int | float = 0.5, ) -> tuple[str, list]: """ Hybrid text-and-embedding doc search. We get top-K from each approach, diff --git a/agents-api/tests/test_docs_routes.py b/agents-api/tests/test_docs_routes.py index 8a3b71ead..5a8356811 100644 --- a/agents-api/tests/test_docs_routes.py +++ b/agents-api/tests/test_docs_routes.py @@ -69,7 +69,7 @@ async def _(make_request=make_request, agent=test_agent): assert response.status_code == 200 assert response.json()["id"] == doc_id assert response.json()["title"] == "Test Agent Doc" - assert response.json()["content"] == "This is a test agent document." + assert response.json()["content"] == ["This is a test agent document."] response = make_request( method="DELETE", From e5881622ec7092b77dbfb5c404807f8f8b66c9d5 Mon Sep 17 00:00:00 2001 From: vedantsahai18 Date: Mon, 6 Jan 2025 21:13:22 -0500 Subject: [PATCH 2/2] fix(migrations): fixed tool unique contraint --- .../migrations/000021_fix_toolname_contraint.down.sql | 10 ++++++++++ .../migrations/000021_fix_toolname_contraint.up.sql | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 memory-store/migrations/000021_fix_toolname_contraint.down.sql create mode 100644 memory-store/migrations/000021_fix_toolname_contraint.up.sql diff --git a/memory-store/migrations/000021_fix_toolname_contraint.down.sql b/memory-store/migrations/000021_fix_toolname_contraint.down.sql new file mode 100644 index 000000000..bf5c7edb7 --- /dev/null +++ b/memory-store/migrations/000021_fix_toolname_contraint.down.sql @@ -0,0 +1,10 @@ +BEGIN; + +-- Drop the updated unique constraint +ALTER TABLE tools DROP CONSTRAINT IF EXISTS ct_unique_name_per_agent; + +-- Restore the original unique constraint (without developer_id) +ALTER TABLE tools ADD CONSTRAINT ct_unique_name_per_agent +UNIQUE (agent_id, name, task_id); + +COMMIT; \ No newline at end of file diff --git a/memory-store/migrations/000021_fix_toolname_contraint.up.sql b/memory-store/migrations/000021_fix_toolname_contraint.up.sql new file mode 100644 index 000000000..0e8be34bb --- /dev/null +++ b/memory-store/migrations/000021_fix_toolname_contraint.up.sql @@ -0,0 +1,10 @@ +BEGIN; + +-- Drop the existing unique constraint +ALTER TABLE tools DROP CONSTRAINT IF EXISTS ct_unique_name_per_agent; + +-- Add the new unique constraint including developer_id +ALTER TABLE tools ADD CONSTRAINT ct_unique_name_per_agent +UNIQUE (developer_id, agent_id, name, task_id); + +COMMIT;