mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-01 10:54:15 +00:00
core[patch[: add exceptions propagation test for astream_events v2 (#23159)
**Description:** `astream_events(version="v2")` didn't propagate exceptions in `langchain-core<=0.2.6`, fixed in the #22916. This PR adds a unit test to check that exceptions are propagated upwards. Co-authored-by: Sergey Kozlov <sergey.kozlov@ludditelabs.io>
This commit is contained in:
parent
50484be330
commit
94452a94b1
@ -2,6 +2,7 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import uuid
|
||||
from functools import partial
|
||||
from itertools import cycle
|
||||
from typing import (
|
||||
Any,
|
||||
@ -346,6 +347,22 @@ async def test_event_stream_with_triple_lambda() -> None:
|
||||
]
|
||||
|
||||
|
||||
async def test_event_stream_exception() -> None:
|
||||
def step(name: str, err: Optional[str], val: str) -> str:
|
||||
if err:
|
||||
raise ValueError(err)
|
||||
return val + name[-1]
|
||||
|
||||
chain = (
|
||||
RunnableLambda(partial(step, "step1", None))
|
||||
| RunnableLambda(partial(step, "step2", "ERR"))
|
||||
| RunnableLambda(partial(step, "step3", None))
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="ERR"):
|
||||
await _collect_events(chain.astream_events("X", version="v2"))
|
||||
|
||||
|
||||
async def test_event_stream_with_triple_lambda_test_filtering() -> None:
|
||||
"""Test filtering based on tags / names"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user