فهرست منبع

enh: tool async support

Timothy J. Baek 10 ماه پیش
والد
کامیت
a2ea6b1b5b
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      backend/main.py

+ 4 - 1
backend/main.py

@@ -309,7 +309,10 @@ async def get_function_call_response(
                             "__id__": tool_id,
                             "__id__": tool_id,
                         }
                         }
 
 
-                    function_result = function(**params)
+                    if inspect.iscoroutinefunction(function):
+                        function_result = await function(**params)
+                    else:
+                        function_result = function(**params)
 
 
                     if hasattr(toolkit_module, "citation") and toolkit_module.citation:
                     if hasattr(toolkit_module, "citation") and toolkit_module.citation:
                         citation = {
                         citation = {