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

Add a filter for labels (tags) in Tool Search #19076

Merged
Merged
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
10 changes: 9 additions & 1 deletion client/src/components/Panels/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import levenshteinDistance from "@/utils/levenshtein";
const FILTER_KEYS = {
id: ["id", "tool_id"],
panel_section_name: ["section", "panel_section_name"],
labels: ["label", "labels", "tag"],
};
const STRING_REPLACEMENTS: string[] = [" ", "-", "\\(", "\\)", "'", ":", `"`];
const MINIMUM_DL_LENGTH = 5; // for Demerau-Levenshtein distance
Expand Down Expand Up @@ -286,7 +287,14 @@ export function searchToolsByKeys(
if (key === "combined") {
actualValue = `${tool.name.trim()} ${tool.description.trim()}`.toLowerCase();
} else {
actualValue = (tool[key as keyof Tool] as string)?.trim().toLowerCase();
const toolVal = tool[key as keyof Tool];
if (typeof toolVal === "string") {
actualValue = toolVal.trim().toLowerCase();
} else if (Array.isArray(toolVal)) {
actualValue = toolVal.join(" ").trim().toLowerCase();
} else if (typeof toolVal === "number") {
actualValue = toolVal.toString().trim().toLowerCase();
}
}

// get all (space separated) words in actualValue for tool (for DL)
Expand Down
Loading