diff --git a/chat/openwebui_functions/studio_langfuse_capture.py b/chat/openwebui_functions/studio_langfuse_capture.py index 457d8d8..80d1db4 100644 --- a/chat/openwebui_functions/studio_langfuse_capture.py +++ b/chat/openwebui_functions/studio_langfuse_capture.py @@ -72,9 +72,9 @@ async def user_message(self, message, history, user_message, chat_id=None, __use return user_message payload = { "body": { + "chat_id": chat_id or str(uuid.uuid4()), "messages": [dict(m) for m in (history or [])] + [{"role": "user", "content": user_message}], "model": kwargs.get("model") or {}, - "metadata": {"chat_id": chat_id or str(uuid.uuid4())}, }, "user": self._user_payload(__user__), } @@ -100,7 +100,6 @@ async def after_chat_completion(self, content, context=None, __user__=None, **kw "body": { "chat_id": ctx.get("chat_id") or "local", "messages": messages, - "metadata": ctx.get("metadata") or {}, }, "user": self._user_payload(__user__), } diff --git a/chat/pipelines_service.py b/chat/pipelines_service.py index b785498..66e4717 100644 --- a/chat/pipelines_service.py +++ b/chat/pipelines_service.py @@ -112,7 +112,7 @@ def _get_langfuse(): def _chat_id(body: dict) -> str: metadata = body.get("metadata") or {} - chat_id = metadata.get("chat_id") or "local" + chat_id = body.get("chat_id") or metadata.get("chat_id") or "local" if chat_id == "local": session_id = metadata.get("session_id") chat_id = f"temporary-session-{session_id}" if session_id else str(uuid.uuid4())