Skip to content

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

Merged
merged 3 commits into from
Aug 29, 2024
Merged

Conversation

SamSaffron
Copy link
Member

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.

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.
Copy link
Contributor

@martin-brennan martin-brennan left a 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
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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 :)

Copy link
Member Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow duh 🤦

@SamSaffron SamSaffron merged commit 41054c4 into main Aug 29, 2024
5 checks passed
@SamSaffron SamSaffron deleted the better-site-setting-search branch August 29, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants