2023-11-27 11:03:24 -05:00
# frozen_string_literal: true
RSpec . describe DiscourseAi :: AiHelper :: ChatThreadTitler do
subject ( :titler ) { described_class . new ( thread ) }
2024-01-29 14:04:25 -05:00
before { SiteSetting . ai_helper_model = " fake:fake " }
2023-11-27 11:03:24 -05:00
fab! ( :thread ) { Fabricate ( :chat_thread ) }
fab! ( :user ) { Fabricate ( :user ) }
describe " # suggested_title " do
it " suggest the first option from the generate_titles prompt " do
titles =
2023-11-28 10:52:22 -05:00
" <item>The solitary horse</item><item>The horse etched in gold</item><item>A horse's infinite journey</item><item>A horse lost in time</item><item>A horse's last ride</item> "
expected_title = " The solitary horse "
2023-11-27 11:03:24 -05:00
result =
2023-11-28 23:17:46 -05:00
DiscourseAi :: Completions :: Llm . with_prepared_responses ( [ titles ] ) { titler . suggested_title }
2023-11-27 11:03:24 -05:00
expect ( result ) . to eq ( expected_title )
end
end
end