|
4 | 4 | import inspect |
5 | 5 | from abc import ABC, abstractmethod |
6 | 6 | from collections.abc import AsyncIterable, AsyncIterator, Awaitable, Callable, Iterator, Mapping, Sequence |
7 | | -from contextlib import AbstractAsyncContextManager, asynccontextmanager, contextmanager |
| 7 | +from contextlib import AbstractAsyncContextManager, AbstractContextManager, asynccontextmanager, contextmanager |
8 | 8 | from types import FrameType |
9 | 9 | from typing import TYPE_CHECKING, Any, Generic, TypeAlias, cast, overload |
10 | 10 |
|
@@ -581,6 +581,44 @@ async def on_complete() -> None: |
581 | 581 | if not yielded: |
582 | 582 | raise exceptions.AgentRunError('Agent run finished without producing a final result') # pragma: no cover |
583 | 583 |
|
| 584 | + @overload |
| 585 | + def run_stream_sync( |
| 586 | + self, |
| 587 | + user_prompt: str | Sequence[_messages.UserContent] | None = None, |
| 588 | + *, |
| 589 | + output_type: None = None, |
| 590 | + message_history: Sequence[_messages.ModelMessage] | None = None, |
| 591 | + deferred_tool_results: DeferredToolResults | None = None, |
| 592 | + model: models.Model | models.KnownModelName | str | None = None, |
| 593 | + deps: AgentDepsT = None, |
| 594 | + model_settings: ModelSettings | None = None, |
| 595 | + usage_limits: _usage.UsageLimits | None = None, |
| 596 | + usage: _usage.RunUsage | None = None, |
| 597 | + infer_name: bool = True, |
| 598 | + toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None, |
| 599 | + builtin_tools: Sequence[AbstractBuiltinTool] | None = None, |
| 600 | + event_stream_handler: EventStreamHandler[AgentDepsT] | None = None, |
| 601 | + ) -> AbstractContextManager[result.StreamedRunResult[AgentDepsT, OutputDataT]]: ... |
| 602 | + |
| 603 | + @overload |
| 604 | + def run_stream_sync( |
| 605 | + self, |
| 606 | + user_prompt: str | Sequence[_messages.UserContent] | None = None, |
| 607 | + *, |
| 608 | + output_type: OutputSpec[RunOutputDataT], |
| 609 | + message_history: Sequence[_messages.ModelMessage] | None = None, |
| 610 | + deferred_tool_results: DeferredToolResults | None = None, |
| 611 | + model: models.Model | models.KnownModelName | str | None = None, |
| 612 | + deps: AgentDepsT = None, |
| 613 | + model_settings: ModelSettings | None = None, |
| 614 | + usage_limits: _usage.UsageLimits | None = None, |
| 615 | + usage: _usage.RunUsage | None = None, |
| 616 | + infer_name: bool = True, |
| 617 | + toolsets: Sequence[AbstractToolset[AgentDepsT]] | None = None, |
| 618 | + builtin_tools: Sequence[AbstractBuiltinTool] | None = None, |
| 619 | + event_stream_handler: EventStreamHandler[AgentDepsT] | None = None, |
| 620 | + ) -> AbstractContextManager[result.StreamedRunResult[AgentDepsT, RunOutputDataT]]: ... |
| 621 | + |
584 | 622 | @contextmanager |
585 | 623 | def run_stream_sync( |
586 | 624 | self, |
|
0 commit comments