Keegan George b515b4f66d
FEATURE: AI Quick Semantic Search (#501)
This PR adds AI semantic search to the search pop available on every page.

It depends on several new and optional settings, like per post embeddings and a reranker model, so this is an experimental endeavour.


---------

Co-authored-by: Rafael Silva <xfalcox@gmail.com>
2024-03-08 13:02:50 -03:00

32 lines
895 B
Plaintext

import Component from "@glimmer/component";
import { inject as service } from "@ember/service";
import { isValidSearchTerm } from "discourse/lib/search";
import i18n from "discourse-common/helpers/i18n";
export default class AiQuickSearchInfo extends Component {
@service search;
@service siteSettings;
@service quickSearch;
get termTooShort() {
// We check the validity again here because the input may have changed
// since the last time we checked, so we may want to stop showing the error
const validity = !isValidSearchTerm(
this.search.activeGlobalSearchTerm,
this.siteSettings
);
return (
validity &&
this.quickSearch.invalidTerm &&
this.search.activeGlobalSearchTerm?.length > 0
);
}
<template>
{{#if this.termTooShort}}
<div class="no-results">{{i18n "search.too_short"}}</div>
{{/if}}
</template>
}