@@ -88,8 +88,8 @@ def trace_as_chain_group(
88
88
Must have ``LANGCHAIN_TRACING_V2`` env var set to true to see the trace in
89
89
LangSmith.
90
90
91
- Returns :
92
- CallbackManagerForChainGroup: The callback manager for the chain group.
91
+ Yields :
92
+ The callback manager for the chain group.
93
93
94
94
Example:
95
95
.. code-block:: python
@@ -170,8 +170,8 @@ async def atrace_as_chain_group(
170
170
metadata (dict[str, Any], optional): The metadata to apply to all runs.
171
171
Defaults to None.
172
172
173
- Returns :
174
- AsyncCallbackManager: The async callback manager for the chain group.
173
+ Yields :
174
+ The async callback manager for the chain group.
175
175
176
176
.. note:
177
177
Must have ``LANGCHAIN_TRACING_V2`` env var set to true to see the trace in
@@ -519,15 +519,12 @@ def on_text(
519
519
self ,
520
520
text : str ,
521
521
** kwargs : Any ,
522
- ) -> Any :
522
+ ) -> None :
523
523
"""Run when a text is received.
524
524
525
525
Args:
526
526
text (str): The received text.
527
527
**kwargs (Any): Additional keyword arguments.
528
-
529
- Returns:
530
- Any: The result of the callback.
531
528
"""
532
529
if not self .handlers :
533
530
return
@@ -607,16 +604,12 @@ async def on_text(
607
604
self ,
608
605
text : str ,
609
606
** kwargs : Any ,
610
- ) -> Any :
607
+ ) -> None :
611
608
"""Run when a text is received.
612
609
613
610
Args:
614
611
text (str): The received text.
615
612
**kwargs (Any): Additional keyword arguments.
616
-
617
- Returns:
618
- Any: The result of the callback.
619
-
620
613
"""
621
614
if not self .handlers :
622
615
return
@@ -914,16 +907,12 @@ def on_chain_error(
914
907
** kwargs ,
915
908
)
916
909
917
- def on_agent_action (self , action : AgentAction , ** kwargs : Any ) -> Any :
910
+ def on_agent_action (self , action : AgentAction , ** kwargs : Any ) -> None :
918
911
"""Run when agent action is received.
919
912
920
913
Args:
921
914
action (AgentAction): The agent action.
922
915
**kwargs (Any): Additional keyword arguments.
923
-
924
- Returns:
925
- Any: The result of the callback.
926
-
927
916
"""
928
917
if not self .handlers :
929
918
return
@@ -938,16 +927,12 @@ def on_agent_action(self, action: AgentAction, **kwargs: Any) -> Any:
938
927
** kwargs ,
939
928
)
940
929
941
- def on_agent_finish (self , finish : AgentFinish , ** kwargs : Any ) -> Any :
930
+ def on_agent_finish (self , finish : AgentFinish , ** kwargs : Any ) -> None :
942
931
"""Run when agent finish is received.
943
932
944
933
Args:
945
934
finish (AgentFinish): The agent finish.
946
935
**kwargs (Any): Additional keyword arguments.
947
-
948
- Returns:
949
- Any: The result of the callback.
950
-
951
936
"""
952
937
if not self .handlers :
953
938
return
@@ -1033,16 +1018,12 @@ async def on_chain_error(
1033
1018
** kwargs ,
1034
1019
)
1035
1020
1036
- async def on_agent_action (self , action : AgentAction , ** kwargs : Any ) -> Any :
1021
+ async def on_agent_action (self , action : AgentAction , ** kwargs : Any ) -> None :
1037
1022
"""Run when agent action is received.
1038
1023
1039
1024
Args:
1040
1025
action (AgentAction): The agent action.
1041
1026
**kwargs (Any): Additional keyword arguments.
1042
-
1043
- Returns:
1044
- Any: The result of the callback.
1045
-
1046
1027
"""
1047
1028
if not self .handlers :
1048
1029
return
@@ -1057,16 +1038,12 @@ async def on_agent_action(self, action: AgentAction, **kwargs: Any) -> Any:
1057
1038
** kwargs ,
1058
1039
)
1059
1040
1060
- async def on_agent_finish (self , finish : AgentFinish , ** kwargs : Any ) -> Any :
1041
+ async def on_agent_finish (self , finish : AgentFinish , ** kwargs : Any ) -> None :
1061
1042
"""Run when agent finish is received.
1062
1043
1063
1044
Args:
1064
1045
finish (AgentFinish): The agent finish.
1065
1046
**kwargs (Any): Additional keyword arguments.
1066
-
1067
- Returns:
1068
- Any: The result of the callback.
1069
-
1070
1047
"""
1071
1048
if not self .handlers :
1072
1049
return
@@ -1562,6 +1539,8 @@ def on_retriever_start(
1562
1539
parent_run_id (UUID, optional): The ID of the parent run. Defaults to None.
1563
1540
**kwargs (Any): Additional keyword arguments.
1564
1541
1542
+ Returns:
1543
+ The callback manager for the retriever run.
1565
1544
"""
1566
1545
if run_id is None :
1567
1546
run_id = uuid .uuid4 ()
@@ -1608,6 +1587,9 @@ def on_custom_event(
1608
1587
data: The data for the adhoc event.
1609
1588
run_id: The ID of the run. Defaults to None.
1610
1589
1590
+ Raises:
1591
+ ValueError: If additional keyword arguments are passed.
1592
+
1611
1593
.. versionadded:: 0.2.14
1612
1594
1613
1595
"""
@@ -1710,8 +1692,8 @@ def __init__(
1710
1692
self .parent_run_manager = parent_run_manager
1711
1693
self .ended = False
1712
1694
1695
+ @override
1713
1696
def copy (self ) -> CallbackManagerForChainGroup :
1714
- """Copy the callback manager."""
1715
1697
return self .__class__ (
1716
1698
handlers = self .handlers .copy (),
1717
1699
inheritable_handlers = self .inheritable_handlers .copy (),
@@ -2099,6 +2081,9 @@ async def on_custom_event(
2099
2081
data: The data for the adhoc event.
2100
2082
run_id: The ID of the run. Defaults to None.
2101
2083
2084
+ Raises:
2085
+ ValueError: If additional keyword arguments are passed.
2086
+
2102
2087
.. versionadded:: 0.2.14
2103
2088
"""
2104
2089
if not self .handlers :
@@ -2249,7 +2234,7 @@ def __init__(
2249
2234
self .ended = False
2250
2235
2251
2236
def copy (self ) -> AsyncCallbackManagerForChainGroup :
2252
- """Copy the async callback manager."""
2237
+ """Return a copy the async callback manager."""
2253
2238
return self .__class__ (
2254
2239
handlers = self .handlers .copy (),
2255
2240
inheritable_handlers = self .inheritable_handlers .copy (),
@@ -2385,6 +2370,9 @@ def _configure(
2385
2370
local_metadata (Optional[dict[str, Any]], optional): The local metadata.
2386
2371
Defaults to None.
2387
2372
2373
+ Raises:
2374
+ RuntimeError: If `LANGCHAIN_TRACING` is set but `LANGCHAIN_TRACING_V2` is not.
2375
+
2388
2376
Returns:
2389
2377
T: The configured callback manager.
2390
2378
"""
@@ -2557,6 +2545,10 @@ async def adispatch_custom_event(
2557
2545
this is not enforced.
2558
2546
config: Optional config object. Mirrors the async API but not strictly needed.
2559
2547
2548
+ Raises:
2549
+ RuntimeError: If there is no parent run ID available to associate
2550
+ the event with.
2551
+
2560
2552
Example:
2561
2553
2562
2554
.. code-block:: python
@@ -2678,6 +2670,10 @@ def dispatch_custom_event(
2678
2670
this is not enforced.
2679
2671
config: Optional config object. Mirrors the async API but not strictly needed.
2680
2672
2673
+ Raises:
2674
+ RuntimeError: If there is no parent run ID available to associate
2675
+ the event with.
2676
+
2681
2677
Example:
2682
2678
2683
2679
.. code-block:: python
0 commit comments