mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-05 19:18:11 +00:00
* UX: Validations to Llm-backed features (except AI Bot) This change is part of an ongoing effort to prevent enabling a broken feature due to lack of configuration. We also want to explicit which provider we are going to use. For example, Claude models are available through AWS Bedrock and Anthropic, but the configuration differs. Validations are: * You must choose a model before enabling the feature. * You must turn off the feature before setting the model to blank. * You must configure each model settings before being able to select it. * Add provider name to summarization options * vLLM can technically support same models as HF * Check we can talk to the selected model * Check for Bedrock instead of anthropic as a site could have both creds setup
23 lines
797 B
Ruby
23 lines
797 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe DiscourseAi::AiHelper::ChatThreadTitler do
|
|
subject(:titler) { described_class.new(thread) }
|
|
|
|
before { SiteSetting.ai_helper_model = "fake:fake" }
|
|
|
|
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 =
|
|
"<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"
|
|
result =
|
|
DiscourseAi::Completions::Llm.with_prepared_responses([titles]) { titler.suggested_title }
|
|
|
|
expect(result).to eq(expected_title)
|
|
end
|
|
end
|
|
end
|