Timothy J. Baek 10 месяцев назад
Родитель
Сommit
0a08a4d2fb
1 измененных файлов с 14 добавлено и 0 удалено
  1. 14 0
      backend/main.py

+ 14 - 0
backend/main.py

@@ -1188,6 +1188,14 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
             to=data["session_id"],
         )
 
+    async def __event_call__(data):
+        response = await sio.call(
+            "chat-events",
+            {"chat_id": data["chat_id"], "message_id": data["id"], "data": data},
+            to=data["session_id"],
+        )
+        return response
+
     def get_priority(function_id):
         function = Functions.get_function_by_id(function_id)
         if function is not None and hasattr(function, "valves"):
@@ -1275,6 +1283,12 @@ async def chat_completed(form_data: dict, user=Depends(get_verified_user)):
                             "__event_emitter__": __event_emitter__,
                         }
 
+                    if "__event_call__" in sig.parameters:
+                        params = {
+                            **params,
+                            "__event_call__": __event_call__,
+                        }
+
                     if inspect.iscoroutinefunction(outlet):
                         data = await outlet(**params)
                     else: