Skip to content
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

CON-232 bring custom docs to top, alphabetize doc results, make scrol… #1239

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion core/context/providers/DocsContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class DocsContextProvider extends BaseContextProvider {
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const { retrieveDocs } = await import("../../indexing/docs/db");

const embeddingsProvider = new TransformersJsEmbeddingsProvider();
const [vector] = await embeddingsProvider.embed([extras.fullInput]);

Expand Down Expand Up @@ -102,6 +101,23 @@ class DocsContextProvider extends BaseContextProvider {
id: config.startUrl,
})),
);

// Sort submenuItems such that the objects with titles which don't occur in configs occur first, and alphabetized
submenuItems.sort((a, b) => {
const aTitleInConfigs = !!configs.find(config => config.title === a.title);
const bTitleInConfigs = !!configs.find(config => config.title === b.title);

// Primary criterion: Items not in configs come first
if (!aTitleInConfigs && bTitleInConfigs) {
return -1;
} else if (aTitleInConfigs && !bTitleInConfigs) {
return 1;
} else {
// Secondary criterion: Alphabetical order when both items are in the same category
return a.title.localeCompare(b.title);
}
});

return submenuItems;
}
}
Expand Down
2 changes: 2 additions & 0 deletions gui/src/components/mainInput/MentionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ const ItemsDiv = styled.div`
0px 10px 20px rgba(0, 0, 0, 0.1);
font-size: 0.9rem;
overflow-x: hidden;
overflow-y: auto;
max-height: 330px;
padding: 0.2rem;
position: relative;

Expand Down
2 changes: 1 addition & 1 deletion gui/src/hooks/useSubmenuContextProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const MINISEARCH_OPTIONS = {
fuzzy: 2,
};

const MAX_LENGTH = 10;
const MAX_LENGTH = 70;

function useSubmenuContextProviders() {
// TODO: Refresh periodically
Expand Down