|
5 | 5 | from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Iterator, Mapping, Sequence
|
6 | 6 | from contextlib import AbstractAsyncContextManager, asynccontextmanager, contextmanager
|
7 | 7 | from types import FrameType
|
8 |
| -from typing import TYPE_CHECKING, Any, Callable, Generic, Union, cast, overload |
| 8 | +from typing import TYPE_CHECKING, Any, Callable, Generic, cast, overload |
9 | 9 |
|
10 | 10 | from typing_extensions import Self, TypeAlias, TypeIs, TypeVar
|
11 | 11 |
|
|
53 | 53 | """Type variable for the result data of a run where `output_type` was customized on the run call."""
|
54 | 54 |
|
55 | 55 | EventStreamHandler: TypeAlias = Callable[
|
56 |
| - [ |
57 |
| - RunContext[AgentDepsT], |
58 |
| - AsyncIterable[Union[_messages.AgentStreamEvent, _messages.HandleResponseEvent]], |
59 |
| - ], |
60 |
| - Awaitable[None], |
| 56 | + [RunContext[AgentDepsT], AsyncIterable[_messages.AgentStreamEvent]], Awaitable[None] |
61 | 57 | ]
|
62 | 58 | """A function that receives agent [`RunContext`][pydantic_ai.tools.RunContext] and an async iterable of events from the model's streaming response and the agent's execution of tools."""
|
63 | 59 |
|
@@ -445,7 +441,9 @@ async def main():
|
445 | 441 | async with node.stream(graph_ctx) as stream:
|
446 | 442 | final_result_event = None
|
447 | 443 |
|
448 |
| - async def stream_to_final(stream: AgentStream) -> AsyncIterator[_messages.AgentStreamEvent]: |
| 444 | + async def stream_to_final( |
| 445 | + stream: AgentStream, |
| 446 | + ) -> AsyncIterator[_messages.ModelResponseStreamEvent]: |
449 | 447 | nonlocal final_result_event
|
450 | 448 | async for event in stream:
|
451 | 449 | yield event
|
|
0 commit comments