Skip to content

Commit 9b7c35c

Browse files
authored
feat: bump vectorize-client to 0.4.x and fix tests (#9)
* feat: bump vectorize-client to 0.4.x and fix tests * ruff * fix env * fix env * fix formt
1 parent 667cdfb commit 9b7c35c

File tree

4 files changed

+49
-34
lines changed

4 files changed

+49
-34
lines changed

.github/workflows/python_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
env:
4545
VECTORIZE_TOKEN: ${{ secrets.VECTORIZE_TOKEN }}
4646
VECTORIZE_ORG: ${{ secrets.VECTORIZE_ORG }}
47-
VECTORIZE_ENV: dev
47+
VECTORIZE_ENV: ${{ secrets.VECTORIZE_ENV }}
4848
run: uv run pytest tests -vv
4949
- name: Minimize uv cache
5050
run: uv cache prune --ci

langchain/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
requires-python = ">=3.9"
1111
dependencies = [
1212
"langchain-core>=0.3.45",
13-
"vectorize-client>=0.1.3",
13+
"vectorize-client>=0.4.0",
1414
]
1515
classifiers = [
1616
"Development Status :: 3 - Alpha",

langchain/tests/test_retrievers.py

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,14 @@ def api_client(api_token: str, environment: str) -> Iterator[ApiClient]:
6868
def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]:
6969
pipelines = v.PipelinesApi(api_client)
7070

71-
connectors_api = v.ConnectorsApi(api_client)
71+
connectors_api = v.SourceConnectorsApi(api_client)
7272
response = connectors_api.create_source_connector(
7373
org_id,
74-
[
75-
v.CreateSourceConnector(
76-
name="from api", type=v.SourceConnectorType.FILE_UPLOAD
77-
)
78-
],
74+
v.CreateSourceConnectorRequest(
75+
v.FileUpload(name="from api", type="FILE_UPLOAD")
76+
),
7977
)
80-
source_connector_id = response.connectors[0].id
78+
source_connector_id = response.connector.id
8179
logging.info("Created source connector %s", source_connector_id)
8280

8381
uploads_api = v.UploadsApi(api_client)
@@ -111,13 +109,17 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]:
111109
else:
112110
logging.info("Upload successful")
113111

114-
ai_platforms = connectors_api.get_ai_platform_connectors(org_id)
112+
ai_platforms = v.AIPlatformConnectorsApi(api_client).get_ai_platform_connectors(
113+
org_id
114+
)
115115
builtin_ai_platform = next(
116116
c.id for c in ai_platforms.ai_platform_connectors if c.type == "VECTORIZE"
117117
)
118118
logging.info("Using AI platform %s", builtin_ai_platform)
119119

120-
vector_databases = connectors_api.get_destination_connectors(org_id)
120+
vector_databases = v.DestinationConnectorsApi(
121+
api_client
122+
).get_destination_connectors(org_id)
121123
builtin_vector_db = next(
122124
c.id for c in vector_databases.destination_connectors if c.type == "VECTORIZE"
123125
)
@@ -127,24 +129,24 @@ def pipeline_id(api_client: v.ApiClient, org_id: str) -> Iterator[str]:
127129
org_id,
128130
v.PipelineConfigurationSchema(
129131
source_connectors=[
130-
v.SourceConnectorSchema(
132+
v.PipelineSourceConnectorSchema(
131133
id=source_connector_id,
132134
type=v.SourceConnectorType.FILE_UPLOAD,
133135
config={},
134136
)
135137
],
136-
destination_connector=v.DestinationConnectorSchema(
138+
destination_connector=v.PipelineDestinationConnectorSchema(
137139
id=builtin_vector_db,
138-
type=v.DestinationConnectorType.VECTORIZE,
140+
type="VECTORIZE",
139141
config={},
140142
),
141-
ai_platform=v.AIPlatformSchema(
143+
ai_platform_connector=v.PipelineAIPlatformConnectorSchema(
142144
id=builtin_ai_platform,
143-
type=v.AIPlatformType.VECTORIZE,
144-
config=v.AIPlatformConfigSchema(),
145+
type="VECTORIZE",
146+
config={},
145147
),
146148
pipeline_name="Test pipeline",
147-
schedule=v.ScheduleSchema(type=v.ScheduleSchemaType.MANUAL),
149+
schedule=v.ScheduleSchema(type="manual"),
148150
),
149151
)
150152
pipeline_id = pipeline_response.data.id
@@ -173,9 +175,15 @@ def test_retrieve_init_args(
173175
)
174176
start = time.time()
175177
while True:
176-
docs = retriever.invoke(input="What are you?")
177-
if len(docs) == 2:
178-
break
178+
try:
179+
docs = retriever.invoke(input="What are you?")
180+
if len(docs) == 2:
181+
break
182+
except Exception as e:
183+
if "503" in str(e):
184+
continue
185+
raise RuntimeError(e) from e
186+
179187
if time.time() - start > 180:
180188
msg = "Docs not retrieved in time"
181189
raise RuntimeError(msg)
@@ -191,15 +199,22 @@ def test_retrieve_invoke_args(
191199
retriever = VectorizeRetriever(environment=environment, api_token=api_token)
192200
start = time.time()
193201
while True:
194-
docs = retriever.invoke(
195-
input="What are you?",
196-
organization=org_id,
197-
pipeline_id=pipeline_id,
198-
num_results=2,
199-
)
200-
if len(docs) == 2:
201-
break
202+
try:
203+
docs = retriever.invoke(
204+
input="What are you?",
205+
organization=org_id,
206+
pipeline_id=pipeline_id,
207+
num_results=2,
208+
)
209+
if len(docs) == 2:
210+
break
211+
212+
except Exception as e:
213+
if "503" in str(e):
214+
continue
215+
raise RuntimeError(e) from e
202216
if time.time() - start > 180:
203217
msg = "Docs not retrieved in time"
204218
raise RuntimeError(msg)
219+
205220
time.sleep(1)

langchain/uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)