@@ -778,14 +778,14 @@ def batch(
778
778
779
779
configs = get_config_list (config , len (inputs ))
780
780
781
- def invoke (value : Input , config : RunnableConfig ) -> Union [Output , Exception ]:
781
+ def invoke (input_ : Input , config : RunnableConfig ) -> Union [Output , Exception ]:
782
782
if return_exceptions :
783
783
try :
784
- return self .invoke (value , config , ** kwargs )
784
+ return self .invoke (input_ , config , ** kwargs )
785
785
except Exception as e :
786
786
return e
787
787
else :
788
- return self .invoke (value , config , ** kwargs )
788
+ return self .invoke (input_ , config , ** kwargs )
789
789
790
790
# If there's only one input, don't bother with the executor
791
791
if len (inputs ) == 1 :
@@ -832,15 +832,17 @@ def batch_as_completed(
832
832
configs = get_config_list (config , len (inputs ))
833
833
834
834
def invoke (
835
- i : int , value : Input , config : RunnableConfig
835
+ i : int , input_ : Input , config : RunnableConfig
836
836
) -> tuple [int , Union [Output , Exception ]]:
837
837
if return_exceptions :
838
838
try :
839
- out : Union [Output , Exception ] = self .invoke (value , config , ** kwargs )
839
+ out : Union [Output , Exception ] = self .invoke (
840
+ input_ , config , ** kwargs
841
+ )
840
842
except Exception as e :
841
843
out = e
842
844
else :
843
- out = self .invoke (value , config , ** kwargs )
845
+ out = self .invoke (input_ , config , ** kwargs )
844
846
845
847
return (i , out )
846
848
@@ -966,24 +968,24 @@ async def abatch_as_completed(
966
968
semaphore = asyncio .Semaphore (max_concurrency ) if max_concurrency else None
967
969
968
970
async def ainvoke_task (
969
- i : int , value : Input , config : RunnableConfig
971
+ i : int , input_ : Input , config : RunnableConfig
970
972
) -> tuple [int , Union [Output , Exception ]]:
971
973
if return_exceptions :
972
974
try :
973
975
out : Union [Output , Exception ] = await self .ainvoke (
974
- value , config , ** kwargs
976
+ input_ , config , ** kwargs
975
977
)
976
978
except Exception as e :
977
979
out = e
978
980
else :
979
- out = await self .ainvoke (value , config , ** kwargs )
981
+ out = await self .ainvoke (input_ , config , ** kwargs )
980
982
return (i , out )
981
983
982
984
coros = [
983
- gated_coro (semaphore , ainvoke_task (i , value , config ))
985
+ gated_coro (semaphore , ainvoke_task (i , input_ , config ))
984
986
if semaphore
985
- else ainvoke_task (i , value , config )
986
- for i , (value , config ) in enumerate (zip (inputs , configs ))
987
+ else ainvoke_task (i , input_ , config )
988
+ for i , (input_ , config ) in enumerate (zip (inputs , configs ))
987
989
]
988
990
989
991
for coro in asyncio .as_completed (coros ):
@@ -1909,7 +1911,7 @@ def _call_with_config(
1909
1911
Callable [[Input , CallbackManagerForChainRun ], Output ],
1910
1912
Callable [[Input , CallbackManagerForChainRun , RunnableConfig ], Output ],
1911
1913
],
1912
- value : Input ,
1914
+ input_ : Input ,
1913
1915
config : Optional [RunnableConfig ],
1914
1916
run_type : Optional [str ] = None ,
1915
1917
serialized : Optional [dict [str , Any ]] = None ,
@@ -1923,7 +1925,7 @@ def _call_with_config(
1923
1925
callback_manager = get_callback_manager_for_config (config )
1924
1926
run_manager = callback_manager .on_chain_start (
1925
1927
serialized ,
1926
- value ,
1928
+ input_ ,
1927
1929
run_type = run_type ,
1928
1930
name = config .get ("run_name" ) or self .get_name (),
1929
1931
run_id = config .pop ("run_id" , None ),
@@ -1936,7 +1938,7 @@ def _call_with_config(
1936
1938
context .run (
1937
1939
call_func_with_variable_args , # type: ignore[arg-type]
1938
1940
func ,
1939
- value ,
1941
+ input_ ,
1940
1942
config ,
1941
1943
run_manager ,
1942
1944
** kwargs ,
@@ -1959,7 +1961,7 @@ async def _acall_with_config(
1959
1961
Awaitable [Output ],
1960
1962
],
1961
1963
],
1962
- value : Input ,
1964
+ input_ : Input ,
1963
1965
config : Optional [RunnableConfig ],
1964
1966
run_type : Optional [str ] = None ,
1965
1967
serialized : Optional [dict [str , Any ]] = None ,
@@ -1973,7 +1975,7 @@ async def _acall_with_config(
1973
1975
callback_manager = get_async_callback_manager_for_config (config )
1974
1976
run_manager = await callback_manager .on_chain_start (
1975
1977
serialized ,
1976
- value ,
1978
+ input_ ,
1977
1979
run_type = run_type ,
1978
1980
name = config .get ("run_name" ) or self .get_name (),
1979
1981
run_id = config .pop ("run_id" , None ),
@@ -1982,7 +1984,7 @@ async def _acall_with_config(
1982
1984
child_config = patch_config (config , callbacks = run_manager .get_child ())
1983
1985
with set_config_context (child_config ) as context :
1984
1986
coro = acall_func_with_variable_args (
1985
- func , value , config , run_manager , ** kwargs
1987
+ func , input_ , config , run_manager , ** kwargs
1986
1988
)
1987
1989
output : Output = await coro_with_context (coro , context )
1988
1990
except BaseException as e :
@@ -3741,7 +3743,7 @@ def invoke(
3741
3743
)
3742
3744
3743
3745
def _invoke_step (
3744
- step : Runnable [Input , Any ], value : Input , config : RunnableConfig , key : str
3746
+ step : Runnable [Input , Any ], input_ : Input , config : RunnableConfig , key : str
3745
3747
) -> Any :
3746
3748
child_config = patch_config (
3747
3749
config ,
@@ -3751,7 +3753,7 @@ def _invoke_step(
3751
3753
with set_config_context (child_config ) as context :
3752
3754
return context .run (
3753
3755
step .invoke ,
3754
- value ,
3756
+ input_ ,
3755
3757
child_config ,
3756
3758
)
3757
3759
@@ -3793,15 +3795,15 @@ async def ainvoke(
3793
3795
)
3794
3796
3795
3797
async def _ainvoke_step (
3796
- step : Runnable [Input , Any ], value : Input , config : RunnableConfig , key : str
3798
+ step : Runnable [Input , Any ], input_ : Input , config : RunnableConfig , key : str
3797
3799
) -> Any :
3798
3800
child_config = patch_config (
3799
3801
config ,
3800
3802
callbacks = run_manager .get_child (f"map:key:{ key } " ),
3801
3803
)
3802
3804
with set_config_context (child_config ) as context :
3803
3805
return await coro_with_context (
3804
- step .ainvoke (value , child_config ), context , create_task = True
3806
+ step .ainvoke (input_ , child_config ), context , create_task = True
3805
3807
)
3806
3808
3807
3809
# gather results from all steps
@@ -4598,7 +4600,7 @@ def __repr__(self) -> str:
4598
4600
4599
4601
def _invoke (
4600
4602
self ,
4601
- value : Input ,
4603
+ input_ : Input ,
4602
4604
run_manager : CallbackManagerForChainRun ,
4603
4605
config : RunnableConfig ,
4604
4606
** kwargs : Any ,
@@ -4607,7 +4609,7 @@ def _invoke(
4607
4609
output : Optional [Output ] = None
4608
4610
for chunk in call_func_with_variable_args (
4609
4611
cast ("Callable[[Input], Iterator[Output]]" , self .func ),
4610
- value ,
4612
+ input_ ,
4611
4613
config ,
4612
4614
run_manager ,
4613
4615
** kwargs ,
@@ -4621,18 +4623,18 @@ def _invoke(
4621
4623
output = chunk
4622
4624
else :
4623
4625
output = call_func_with_variable_args (
4624
- self .func , value , config , run_manager , ** kwargs
4626
+ self .func , input_ , config , run_manager , ** kwargs
4625
4627
)
4626
4628
# If the output is a Runnable, invoke it
4627
4629
if isinstance (output , Runnable ):
4628
4630
recursion_limit = config ["recursion_limit" ]
4629
4631
if recursion_limit <= 0 :
4630
4632
msg = (
4631
- f"Recursion limit reached when invoking { self } with input { value } ."
4633
+ f"Recursion limit reached when invoking { self } with input { input_ } ."
4632
4634
)
4633
4635
raise RecursionError (msg )
4634
4636
output = output .invoke (
4635
- value ,
4637
+ input_ ,
4636
4638
patch_config (
4637
4639
config ,
4638
4640
callbacks = run_manager .get_child (),
@@ -4921,13 +4923,13 @@ async def _atransform(
4921
4923
raise TypeError (msg )
4922
4924
4923
4925
def func (
4924
- value : Input ,
4926
+ input_ : Input ,
4925
4927
run_manager : AsyncCallbackManagerForChainRun ,
4926
4928
config : RunnableConfig ,
4927
4929
** kwargs : Any ,
4928
4930
) -> Output :
4929
4931
return call_func_with_variable_args (
4930
- self .func , value , config , run_manager .get_sync (), ** kwargs
4932
+ self .func , input_ , config , run_manager .get_sync (), ** kwargs
4931
4933
)
4932
4934
4933
4935
@wraps (func )
0 commit comments