@@ -458,7 +458,7 @@ async def _(user_input: str):
458
458
user_input ,
459
459
kwargs = kwargs ,
460
460
echo = echo or "none" ,
461
- content = content ,
461
+ stream = " content" if content == "all" else "text" ,
462
462
)
463
463
)
464
464
else :
@@ -569,7 +569,7 @@ def chat(
569
569
self ._chat_impl (
570
570
turn ,
571
571
echo = echo ,
572
- content = "text" ,
572
+ yield_content = False ,
573
573
stream = stream ,
574
574
kwargs = kwargs ,
575
575
)
@@ -619,7 +619,7 @@ async def chat_async(
619
619
self ._chat_impl_async (
620
620
turn ,
621
621
echo = echo ,
622
- content = "text" ,
622
+ yield_content = False ,
623
623
stream = stream ,
624
624
kwargs = kwargs ,
625
625
),
@@ -635,7 +635,7 @@ async def chat_async(
635
635
def stream (
636
636
self ,
637
637
* args : Content | str ,
638
- content : Literal ["text" ],
638
+ stream : Literal ["text" ],
639
639
echo : EchoOptions = "none" ,
640
640
kwargs : Optional [SubmitInputArgsT ] = None ,
641
641
) -> Generator [str , None , None ]: ...
@@ -644,16 +644,16 @@ def stream(
644
644
def stream (
645
645
self ,
646
646
* args : Content | str ,
647
- content : Literal ["all" ],
648
647
echo : EchoOptions = "none" ,
648
+ stream : Literal ["content" ],
649
649
kwargs : Optional [SubmitInputArgsT ] = None ,
650
650
) -> Generator [str | ContentToolRequest | ContentToolResult , None , None ]: ...
651
651
652
652
def stream (
653
653
self ,
654
654
* args : Content | str ,
655
655
echo : EchoOptions = "none" ,
656
- content : Literal ["text" , "all " ] = "text" ,
656
+ stream : Literal ["text" , "content " ] = "text" ,
657
657
kwargs : Optional [SubmitInputArgsT ] = None ,
658
658
) -> Generator [str | ContentToolRequest | ContentToolResult , None , None ]:
659
659
"""
@@ -667,7 +667,8 @@ def stream(
667
667
Whether to echo text content, all content (i.e., tool calls), or no
668
668
content.
669
669
content
670
- Whether to yield just text content, or all content (i.e., tool calls).
670
+ Whether to yield just text content, or rich content objects (e.g., tool
671
+ calls) when relevant.
671
672
kwargs
672
673
Additional keyword arguments to pass to the method used for requesting
673
674
the response.
@@ -686,7 +687,7 @@ def stream(
686
687
turn ,
687
688
stream = True ,
688
689
echo = echo ,
689
- content = content ,
690
+ yield_content = stream == " content" ,
690
691
kwargs = kwargs ,
691
692
)
692
693
@@ -703,7 +704,7 @@ def wrapper() -> Generator[
703
704
async def stream_async (
704
705
self ,
705
706
* args : Content | str ,
706
- content : Literal ["text" ],
707
+ stream : Literal ["text" ],
707
708
echo : EchoOptions = "none" ,
708
709
kwargs : Optional [SubmitInputArgsT ] = None ,
709
710
) -> AsyncGenerator [str , None ]: ...
@@ -712,7 +713,7 @@ async def stream_async(
712
713
async def stream_async (
713
714
self ,
714
715
* args : Content | str ,
715
- content : Literal ["all " ],
716
+ stream : Literal ["content " ],
716
717
echo : EchoOptions = "none" ,
717
718
kwargs : Optional [SubmitInputArgsT ] = None ,
718
719
) -> AsyncGenerator [str | ContentToolRequest | ContentToolResult , None ]: ...
@@ -721,7 +722,7 @@ async def stream_async(
721
722
self ,
722
723
* args : Content | str ,
723
724
echo : EchoOptions = "none" ,
724
- content : Literal ["text" , "all " ] = "text" ,
725
+ stream : Literal ["text" , "content " ] = "text" ,
725
726
kwargs : Optional [SubmitInputArgsT ] = None ,
726
727
) -> AsyncGenerator [str | ContentToolRequest | ContentToolResult , None ]:
727
728
"""
@@ -758,7 +759,7 @@ async def wrapper() -> AsyncGenerator[
758
759
turn ,
759
760
stream = True ,
760
761
echo = echo ,
761
- content = content ,
762
+ yield_content = stream == " content" ,
762
763
kwargs = kwargs ,
763
764
):
764
765
yield chunk
@@ -1192,7 +1193,7 @@ def _chat_impl(
1192
1193
self ,
1193
1194
user_turn : Turn ,
1194
1195
echo : EchoOptions ,
1195
- content : Literal ["text" ],
1196
+ yield_content : Literal [False ],
1196
1197
stream : bool ,
1197
1198
kwargs : Optional [SubmitInputArgsT ] = None ,
1198
1199
) -> Generator [str , None , None ]: ...
@@ -1202,7 +1203,7 @@ def _chat_impl(
1202
1203
self ,
1203
1204
user_turn : Turn ,
1204
1205
echo : EchoOptions ,
1205
- content : Literal ["all" ],
1206
+ yield_content : Literal [True ],
1206
1207
stream : bool ,
1207
1208
kwargs : Optional [SubmitInputArgsT ] = None ,
1208
1209
) -> Generator [str | ContentToolRequest | ContentToolResult , None , None ]: ...
@@ -1211,7 +1212,7 @@ def _chat_impl(
1211
1212
self ,
1212
1213
user_turn : Turn ,
1213
1214
echo : EchoOptions ,
1214
- content : Literal [ "text" , "all" ] ,
1215
+ yield_content : bool ,
1215
1216
stream : bool ,
1216
1217
kwargs : Optional [SubmitInputArgsT ] = None ,
1217
1218
) -> Generator [str | ContentToolRequest | ContentToolResult , None , None ]:
@@ -1234,12 +1235,12 @@ def _chat_impl(
1234
1235
if isinstance (x , ContentToolRequest ):
1235
1236
if echo == "output" :
1236
1237
self ._echo_content (f"\n \n { x } \n \n " )
1237
- if content == "all" :
1238
+ if yield_content :
1238
1239
yield x
1239
1240
res = self ._invoke_tool (x )
1240
1241
if echo == "output" :
1241
1242
self ._echo_content (f"\n \n { res } \n \n " )
1242
- if content == "all" :
1243
+ if yield_content :
1243
1244
yield res
1244
1245
results .append (res )
1245
1246
@@ -1251,7 +1252,7 @@ def _chat_impl_async(
1251
1252
self ,
1252
1253
user_turn : Turn ,
1253
1254
echo : EchoOptions ,
1254
- content : Literal ["text" ],
1255
+ yield_content : Literal [False ],
1255
1256
stream : bool ,
1256
1257
kwargs : Optional [SubmitInputArgsT ] = None ,
1257
1258
) -> AsyncGenerator [str , None ]: ...
@@ -1261,7 +1262,7 @@ def _chat_impl_async(
1261
1262
self ,
1262
1263
user_turn : Turn ,
1263
1264
echo : EchoOptions ,
1264
- content : Literal ["all" ],
1265
+ yield_content : Literal [True ],
1265
1266
stream : bool ,
1266
1267
kwargs : Optional [SubmitInputArgsT ] = None ,
1267
1268
) -> AsyncGenerator [str | ContentToolRequest | ContentToolResult , None ]: ...
@@ -1270,7 +1271,7 @@ async def _chat_impl_async(
1270
1271
self ,
1271
1272
user_turn : Turn ,
1272
1273
echo : EchoOptions ,
1273
- content : Literal [ "text" , "all" ] ,
1274
+ yield_content : bool ,
1274
1275
stream : bool ,
1275
1276
kwargs : Optional [SubmitInputArgsT ] = None ,
1276
1277
) -> AsyncGenerator [str | ContentToolRequest | ContentToolResult , None ]:
@@ -1293,12 +1294,12 @@ async def _chat_impl_async(
1293
1294
if isinstance (x , ContentToolRequest ):
1294
1295
if echo == "output" :
1295
1296
self ._echo_content (f"\n \n { x } \n \n " )
1296
- if content == "all" :
1297
+ if yield_content :
1297
1298
yield x
1298
1299
res = await self ._invoke_tool_async (x )
1299
1300
if echo == "output" :
1300
1301
self ._echo_content (f"\n \n { res } \n \n " )
1301
- if content == "all" :
1302
+ if yield_content :
1302
1303
yield res
1303
1304
else :
1304
1305
yield "\n \n "
0 commit comments