From e5f17c026e4418f03135dca6397ab0d51eb706ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 12 Aug 2025 08:30:29 +0200 Subject: [PATCH 1/5] feat: bump vectorize-client to 0.4.x and fix tests --- langchain/pyproject.toml | 2 +- langchain/tests/test_retrievers.py | 31 +++++++++++++++--------------- langchain/uv.lock | 10 +++++----- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/langchain/pyproject.toml b/langchain/pyproject.toml index f999b28..ac2e77f 100644 --- a/langchain/pyproject.toml +++ b/langchain/pyproject.toml @@ -10,7 +10,7 @@ authors = [ requires-python = ">=3.9" dependencies = [ "langchain-core>=0.3.45", - "vectorize-client>=0.1.3", + "vectorize-client>=0.4.0", ] classifiers = [ "Development Status :: 3 - Alpha", diff --git a/langchain/tests/test_retrievers.py b/langchain/tests/test_retrievers.py index e676666..b1cbaa8 100644 --- a/langchain/tests/test_retrievers.py +++ b/langchain/tests/test_retrievers.py @@ -68,16 +68,15 @@ def api_client(api_token: str, environment: str) -> Iterator[ApiClient]: def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]: pipelines = v.PipelinesApi(api_client) - connectors_api = v.ConnectorsApi(api_client) + connectors_api = v.SourceConnectorsApi(api_client) response = connectors_api.create_source_connector( org_id, - [ - v.CreateSourceConnector( - name="from api", type=v.SourceConnectorType.FILE_UPLOAD - ) - ], + v.CreateSourceConnectorRequest(v.FileUpload( + name="from api", + type="FILE_UPLOAD" + )) ) - source_connector_id = response.connectors[0].id + source_connector_id = response.connector.id logging.info("Created source connector %s", source_connector_id) uploads_api = v.UploadsApi(api_client) @@ -111,13 +110,13 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]: else: logging.info("Upload successful") - ai_platforms = connectors_api.get_ai_platform_connectors(org_id) + ai_platforms = v.AIPlatformConnectorsApi(api_client).get_ai_platform_connectors(org_id) builtin_ai_platform = next( c.id for c in ai_platforms.ai_platform_connectors if c.type == "VECTORIZE" ) logging.info("Using AI platform %s", builtin_ai_platform) - vector_databases = connectors_api.get_destination_connectors(org_id) + vector_databases = v.DestinationConnectorsApi(api_client).get_destination_connectors(org_id) builtin_vector_db = next( c.id for c in vector_databases.destination_connectors if c.type == "VECTORIZE" ) @@ -127,24 +126,24 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]: org_id, v.PipelineConfigurationSchema( source_connectors=[ - v.SourceConnectorSchema( + v.PipelineSourceConnectorSchema( id=source_connector_id, type=v.SourceConnectorType.FILE_UPLOAD, config={}, ) ], - destination_connector=v.DestinationConnectorSchema( + destination_connector=v.PipelineDestinationConnectorSchema( id=builtin_vector_db, - type=v.DestinationConnectorType.VECTORIZE, + type="VECTORIZE", config={}, ), - ai_platform=v.AIPlatformSchema( + ai_platform_connector=v.PipelineAIPlatformConnectorSchema( id=builtin_ai_platform, - type=v.AIPlatformType.VECTORIZE, - config=v.AIPlatformConfigSchema(), + type="VECTORIZE", + config={}, ), pipeline_name="Test pipeline", - schedule=v.ScheduleSchema(type=v.ScheduleSchemaType.MANUAL), + schedule=v.ScheduleSchema(type="manual"), ), ) pipeline_id = pipeline_response.data.id diff --git a/langchain/uv.lock b/langchain/uv.lock index 0b7a37e..82abf9a 100644 --- a/langchain/uv.lock +++ b/langchain/uv.lock @@ -296,7 +296,7 @@ wheels = [ [[package]] name = "langchain-vectorize" -version = "0.0.1" +version = "0.0.3" source = { editable = "." } dependencies = [ { name = "langchain-core" }, @@ -313,7 +313,7 @@ dev = [ [package.metadata] requires-dist = [ { name = "langchain-core", specifier = ">=0.3.45" }, - { name = "vectorize-client", specifier = ">=0.1.3" }, + { name = "vectorize-client", specifier = ">=0.4.0" }, ] [package.metadata.requires-dev] @@ -825,7 +825,7 @@ wheels = [ [[package]] name = "vectorize-client" -version = "0.1.3" +version = "0.4.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "pydantic" }, @@ -833,9 +833,9 @@ dependencies = [ { name = "typing-extensions" }, { name = "urllib3" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/8b/16/de5a7590f27efb6d38ca6cf0b128a5cbd7f4d72d8919823e4e27feee6c6c/vectorize_client-0.1.3.tar.gz", hash = "sha256:20b91f7b25d79f0c3f0890ad932e9d4abac94f57ed616bb83c176ceebbf6ed04", size = 46374 } +sdist = { url = "https://files.pythonhosted.org/packages/6f/d0/706ead5eedbb8b03eeb051f0215a3afe5ba6abe0eb25fb5a570d87ffc711/vectorize_client-0.4.0.tar.gz", hash = "sha256:ebf1ad501d203ea3f313699178401ad20cbc5d6ddbba5233951a3e268f6c51e0", size = 90716 } wheels = [ - { url = "https://files.pythonhosted.org/packages/48/b0/595a7c78a8c7860135fb09ad24f0b032fa11f1615b6f7337f704e1ed23ef/vectorize_client-0.1.3-py3-none-any.whl", hash = "sha256:e30a0148ed9d1a9ba2d1ce6221524b094a04d38310b4e5e2f1a22e8ee40b83f8", size = 144706 }, + { url = "https://files.pythonhosted.org/packages/10/bf/4ee08bdff44503624d0e338479155e0146717817e402d2666337d09ea69b/vectorize_client-0.4.0-py3-none-any.whl", hash = "sha256:76f10d8ef235505fa3cb4ec96ac53176bad9a7e2f99ff0c5b294636c8f813fe3", size = 370425 }, ] [[package]] From 3d56407f3fdb7a2aa4f322d7710f1b344d041203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 12 Aug 2025 08:33:10 +0200 Subject: [PATCH 2/5] ruff --- langchain/tests/test_retrievers.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/langchain/tests/test_retrievers.py b/langchain/tests/test_retrievers.py index b1cbaa8..2e0120c 100644 --- a/langchain/tests/test_retrievers.py +++ b/langchain/tests/test_retrievers.py @@ -71,10 +71,9 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]: connectors_api = v.SourceConnectorsApi(api_client) response = connectors_api.create_source_connector( org_id, - v.CreateSourceConnectorRequest(v.FileUpload( - name="from api", - type="FILE_UPLOAD" - )) + v.CreateSourceConnectorRequest( + v.FileUpload(name="from api", type="FILE_UPLOAD") + ), ) source_connector_id = response.connector.id logging.info("Created source connector %s", source_connector_id) @@ -110,13 +109,17 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]: else: logging.info("Upload successful") - ai_platforms = v.AIPlatformConnectorsApi(api_client).get_ai_platform_connectors(org_id) + ai_platforms = v.AIPlatformConnectorsApi(api_client).get_ai_platform_connectors( + org_id + ) builtin_ai_platform = next( c.id for c in ai_platforms.ai_platform_connectors if c.type == "VECTORIZE" ) logging.info("Using AI platform %s", builtin_ai_platform) - vector_databases = v.DestinationConnectorsApi(api_client).get_destination_connectors(org_id) + vector_databases = v.DestinationConnectorsApi( + api_client + ).get_destination_connectors(org_id) builtin_vector_db = next( c.id for c in vector_databases.destination_connectors if c.type == "VECTORIZE" ) From b065e849edef027832426733c6fa8da308b40f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 12 Aug 2025 09:25:10 +0200 Subject: [PATCH 3/5] fix env --- .github/workflows/python_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_test.yml b/.github/workflows/python_test.yml index 9ffe449..ad11a88 100644 --- a/.github/workflows/python_test.yml +++ b/.github/workflows/python_test.yml @@ -44,7 +44,7 @@ jobs: env: VECTORIZE_TOKEN: ${{ secrets.VECTORIZE_TOKEN }} VECTORIZE_ORG: ${{ secrets.VECTORIZE_ORG }} - VECTORIZE_ENV: dev + VECTORIZE_ENV: ${{ secrets.VECTORIZE_ENV }} run: uv run pytest tests -vv - name: Minimize uv cache run: uv cache prune --ci From 0e76b3d5e7594cf546b92b20a3baa25631682775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Tue, 12 Aug 2025 09:31:58 +0200 Subject: [PATCH 4/5] fix env --- langchain/tests/test_retrievers.py | 37 +++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/langchain/tests/test_retrievers.py b/langchain/tests/test_retrievers.py index 2e0120c..09d7093 100644 --- a/langchain/tests/test_retrievers.py +++ b/langchain/tests/test_retrievers.py @@ -175,9 +175,16 @@ def test_retrieve_init_args( ) start = time.time() while True: - docs = retriever.invoke(input="What are you?") - if len(docs) == 2: - break + try: + docs = retriever.invoke(input="What are you?") + if len(docs) == 2: + break + except Exception as e: + logging.exception("Error during retrieval: %s", e) + if "503" in str(e): + continue + raise e + if time.time() - start > 180: msg = "Docs not retrieved in time" raise RuntimeError(msg) @@ -193,15 +200,23 @@ def test_retrieve_invoke_args( retriever = VectorizeRetriever(environment=environment, api_token=api_token) start = time.time() while True: - docs = retriever.invoke( - input="What are you?", - organization=org_id, - pipeline_id=pipeline_id, - num_results=2, - ) - if len(docs) == 2: - break + try: + docs = retriever.invoke( + input="What are you?", + organization=org_id, + pipeline_id=pipeline_id, + num_results=2, + ) + if len(docs) == 2: + break + + except Exception as e: + logging.exception("Error during retrieval: %s", e) + if "503" in str(e): + continue + raise e if time.time() - start > 180: msg = "Docs not retrieved in time" raise RuntimeError(msg) + time.sleep(1) From ca5dd05a36281429ed1cbef5b12d74dfd7a71fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Wed, 13 Aug 2025 10:26:18 +0200 Subject: [PATCH 5/5] fix formt --- langchain/tests/test_retrievers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/langchain/tests/test_retrievers.py b/langchain/tests/test_retrievers.py index 09d7093..024b9a0 100644 --- a/langchain/tests/test_retrievers.py +++ b/langchain/tests/test_retrievers.py @@ -180,10 +180,9 @@ def test_retrieve_init_args( if len(docs) == 2: break except Exception as e: - logging.exception("Error during retrieval: %s", e) if "503" in str(e): continue - raise e + raise RuntimeError(e) from e if time.time() - start > 180: msg = "Docs not retrieved in time" @@ -211,10 +210,9 @@ def test_retrieve_invoke_args( break except Exception as e: - logging.exception("Error during retrieval: %s", e) if "503" in str(e): continue - raise e + raise RuntimeError(e) from e if time.time() - start > 180: msg = "Docs not retrieved in time" raise RuntimeError(msg)