Skip to content

Commit

Permalink
Add a filter for labels (tags) in Tool Search
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Oct 29, 2024
1 parent 6586093 commit 28596d3
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 28596d3

Please sign in to comment.