Track Langfuse sessions and users (#174)

This commit is contained in:
Juan José Mata
2025-10-01 19:46:25 +02:00
committed by GitHub
parent ed99a4dcab
commit cbc653a63a
4 changed files with 63 additions and 8 deletions

View File

@@ -67,7 +67,9 @@ class Assistant::Responder
functions: function_tool_caller.function_definitions,
function_results: function_results,
streamer: streamer,
previous_response_id: previous_response_id
previous_response_id: previous_response_id,
session_id: chat_session_id,
user_identifier: chat_user_identifier
)
unless response.success?
@@ -84,4 +86,18 @@ class Assistant::Responder
def listeners
@listeners ||= Hash.new { |h, k| h[k] = [] }
end
def chat_session_id
chat&.id&.to_s
end
def chat_user_identifier
return unless chat&.user_id
::Digest::SHA256.hexdigest(chat.user_id.to_s)
end
def chat
@chat ||= message.chat
end
end