Skip to content

Commit 0e76b3d

Browse files
committed
fix env
1 parent b065e84 commit 0e76b3d

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

langchain/tests/test_retrievers.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,16 @@ def test_retrieve_init_args(
175175
)
176176
start = time.time()
177177
while True:
178-
docs = retriever.invoke(input="What are you?")
179-
if len(docs) == 2:
180-
break
178+
try:
179+
docs = retriever.invoke(input="What are you?")
180+
if len(docs) == 2:
181+
break
182+
except Exception as e:
183+
logging.exception("Error during retrieval: %s", e)
184+
if "503" in str(e):
185+
continue
186+
raise e
187+
181188
if time.time() - start > 180:
182189
msg = "Docs not retrieved in time"
183190
raise RuntimeError(msg)
@@ -193,15 +200,23 @@ def test_retrieve_invoke_args(
193200
retriever = VectorizeRetriever(environment=environment, api_token=api_token)
194201
start = time.time()
195202
while True:
196-
docs = retriever.invoke(
197-
input="What are you?",
198-
organization=org_id,
199-
pipeline_id=pipeline_id,
200-
num_results=2,
201-
)
202-
if len(docs) == 2:
203-
break
203+
try:
204+
docs = retriever.invoke(
205+
input="What are you?",
206+
organization=org_id,
207+
pipeline_id=pipeline_id,
208+
num_results=2,
209+
)
210+
if len(docs) == 2:
211+
break
212+
213+
except Exception as e:
214+
logging.exception("Error during retrieval: %s", e)
215+
if "503" in str(e):
216+
continue
217+
raise e
204218
if time.time() - start > 180:
205219
msg = "Docs not retrieved in time"
206220
raise RuntimeError(msg)
221+
207222
time.sleep(1)

0 commit comments

Comments
 (0)