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 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..024b9a0 100644 --- a/langchain/tests/test_retrievers.py +++ b/langchain/tests/test_retrievers.py @@ -68,16 +68,14 @@ 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 +109,17 @@ 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 +129,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 @@ -173,9 +175,15 @@ 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: + if "503" in str(e): + continue + raise RuntimeError(e) from e + if time.time() - start > 180: msg = "Docs not retrieved in time" raise RuntimeError(msg) @@ -191,15 +199,22 @@ 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: + if "503" in str(e): + continue + raise RuntimeError(e) from e if time.time() - start > 180: msg = "Docs not retrieved in time" raise RuntimeError(msg) + time.sleep(1) 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]]