@@ -229,7 +229,7 @@ def reply_func(
229
229
"reset_config" : reset_config ,
230
230
},
231
231
)
232
- if ignore_async_in_sync_chat and asyncio . coroutines .iscoroutinefunction (reply_func ):
232
+ if ignore_async_in_sync_chat and inspect .iscoroutinefunction (reply_func ):
233
233
self ._ignore_async_func_in_sync_chat_list .append (reply_func )
234
234
235
235
@property
@@ -629,7 +629,7 @@ def _raise_exception_on_async_reply_functions(self) -> None:
629
629
self ._ignore_async_func_in_sync_chat_list
630
630
)
631
631
632
- async_reply_functions = [f for f in reply_functions if asyncio . coroutines .iscoroutinefunction (f )]
632
+ async_reply_functions = [f for f in reply_functions if inspect .iscoroutinefunction (f )]
633
633
if async_reply_functions != []:
634
634
msg = (
635
635
"Async reply functions can only be used with ConversableAgent.a_initiate_chat(). The following async reply functions are found: "
@@ -849,7 +849,7 @@ def generate_function_call_reply(
849
849
if "function_call" in message and message ["function_call" ]:
850
850
func_call = message ["function_call" ]
851
851
func = self ._function_map .get (func_call .get ("name" , None ), None )
852
- if asyncio . coroutines .iscoroutinefunction (func ):
852
+ if inspect .iscoroutinefunction (func ):
853
853
return False , None
854
854
855
855
_ , func_return = self .execute_function (message ["function_call" ])
@@ -877,7 +877,7 @@ async def a_generate_function_call_reply(
877
877
func_call = message ["function_call" ]
878
878
func_name = func_call .get ("name" , "" )
879
879
func = self ._function_map .get (func_name , None )
880
- if func and asyncio . coroutines .iscoroutinefunction (func ):
880
+ if func and inspect .iscoroutinefunction (func ):
881
881
_ , func_return = await self .a_execute_function (func_call )
882
882
return True , func_return
883
883
@@ -906,7 +906,7 @@ def generate_tool_calls_reply(
906
906
id = tool_call ["id" ]
907
907
function_call = tool_call .get ("function" , {})
908
908
func = self ._function_map .get (function_call .get ("name" , None ), None )
909
- if asyncio . coroutines .iscoroutinefunction (func ):
909
+ if inspect .iscoroutinefunction (func ):
910
910
continue
911
911
_ , func_return = self .execute_function (function_call )
912
912
tool_returns .append (
@@ -1231,7 +1231,7 @@ def generate_reply(
1231
1231
reply_func = reply_func_tuple ["reply_func" ]
1232
1232
if exclude and reply_func in exclude :
1233
1233
continue
1234
- if asyncio . coroutines .iscoroutinefunction (reply_func ):
1234
+ if inspect .iscoroutinefunction (reply_func ):
1235
1235
continue
1236
1236
if self ._match_trigger (reply_func_tuple ["trigger" ], sender ):
1237
1237
final , reply = reply_func (self , messages = messages , sender = sender , config = reply_func_tuple ["config" ])
@@ -1288,7 +1288,7 @@ async def a_generate_reply(
1288
1288
if exclude and reply_func in exclude :
1289
1289
continue
1290
1290
if self ._match_trigger (reply_func_tuple ["trigger" ], sender ):
1291
- if asyncio . coroutines .iscoroutinefunction (reply_func ):
1291
+ if inspect .iscoroutinefunction (reply_func ):
1292
1292
final , reply = await reply_func (
1293
1293
self , messages = messages , sender = sender , config = reply_func_tuple ["config" ]
1294
1294
)
@@ -1537,7 +1537,7 @@ async def a_execute_function(self, func_call):
1537
1537
flush = True ,
1538
1538
)
1539
1539
try :
1540
- if asyncio . coroutines .iscoroutinefunction (func ):
1540
+ if inspect .iscoroutinefunction (func ):
1541
1541
content = await func (** arguments )
1542
1542
else :
1543
1543
# Fallback to sync function if the function is not async
0 commit comments