mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Track Langfuse sessions and users (#174)
This commit is contained in:
@@ -12,6 +12,8 @@ class AssistantTest < ActiveSupport::TestCase
|
||||
)
|
||||
@assistant = Assistant.for_chat(@chat)
|
||||
@provider = mock
|
||||
@expected_session_id = @chat.id.to_s
|
||||
@expected_user_identifier = ::Digest::SHA256.hexdigest(@chat.user_id.to_s)
|
||||
end
|
||||
|
||||
test "errors get added to chat" do
|
||||
@@ -46,6 +48,8 @@ class AssistantTest < ActiveSupport::TestCase
|
||||
response = provider_success_response(response_chunk.data)
|
||||
|
||||
@provider.expects(:chat_response).with do |message, **options|
|
||||
assert_equal @expected_session_id, options[:session_id]
|
||||
assert_equal @expected_user_identifier, options[:user_identifier]
|
||||
text_chunks.each do |text_chunk|
|
||||
options[:streamer].call(text_chunk)
|
||||
end
|
||||
@@ -98,6 +102,8 @@ class AssistantTest < ActiveSupport::TestCase
|
||||
sequence = sequence("provider_chat_response")
|
||||
|
||||
@provider.expects(:chat_response).with do |message, **options|
|
||||
assert_equal @expected_session_id, options[:session_id]
|
||||
assert_equal @expected_user_identifier, options[:user_identifier]
|
||||
call2_text_chunks.each do |text_chunk|
|
||||
options[:streamer].call(text_chunk)
|
||||
end
|
||||
@@ -107,6 +113,8 @@ class AssistantTest < ActiveSupport::TestCase
|
||||
end.returns(call2_response).once.in_sequence(sequence)
|
||||
|
||||
@provider.expects(:chat_response).with do |message, **options|
|
||||
assert_equal @expected_session_id, options[:session_id]
|
||||
assert_equal @expected_user_identifier, options[:user_identifier]
|
||||
options[:streamer].call(call1_response_chunk)
|
||||
true
|
||||
end.returns(call1_response).once.in_sequence(sequence)
|
||||
|
||||
Reference in New Issue
Block a user