-
Notifications
You must be signed in to change notification settings - Fork 36
FEATURE: improve site setting search #780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This improves the site setting search so it performs a somewhat fuzzy match. Previously it did not handle seperators such as "space" and a term such as "min_post_length" would not find "min_first_post_length" A more liberal search algorithm makes it easier to the AI to navigate settings.
obviously broken. If parameter.enum is a tracked array it will return the object cause embers and helper implementation. This corrects an issue where enum keeps on selecting itself by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with comments about stubbing all settings
described_class.new({ query: query }, bot_user: bot_user, llm: llm) | ||
def search_settings(query, mock: true) | ||
search = described_class.new({ query: query }, bot_user: bot_user, llm: llm) | ||
search.all_settings = fake_settings if mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need an after
block to restore the original value of this, or reset it to nil so the memoization can kick in and re-initialize the settings in search_settings.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise some test flakiness may occur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative approach is to do DiscourseAi::AiBot::Tools::SearchSettings.any_instance.stubs(:site_settings).returns(mock)
, then that will automatically get cleaned up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or doing the above with SiteSetting.all_settings
would avoid needing to add an all_settings
method in that class entirely :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need, this is just defining an instance :) the instance and the override vanish after the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow duh 🤦
This improves the site setting search so it performs a somewhat
fuzzy match.
Previously it did not handle seperators such as "space" and a
term such as "min_post_length" would not find "min_first_post_length"
A more liberal search algorithm makes it easier to the AI to
navigate settings.