Fuzzy search openrouter models

This commit is contained in:
Saoud Rizwan
2024-10-04 00:57:58 -04:00
parent ecff59004d
commit 4573010e16
2 changed files with 56 additions and 15 deletions

View File

@@ -85,6 +85,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
((a.tokensIn || 0) + (a.tokensOut || 0) + (a.cacheWrites || 0) + (a.cacheReads || 0))
)
case "mostRelevant":
// NOTE: you must never sort directly on object since it will cause members to be reordered
return searchQuery ? 0 : b.ts - a.ts // Keep fuse order if searching, otherwise sort by newest
case "newest":
default:
@@ -427,7 +428,10 @@ const ExportButton = ({ itemId }: { itemId: string }) => (
)
// https://gist.github.com/evenfrost/1ba123656ded32fb7a0cd4651efd4db0
const highlight = (fuseSearchResult: FuseResult<any>[], highlightClassName: string = "history-item-highlight") => {
export const highlight = (
fuseSearchResult: FuseResult<any>[],
highlightClassName: string = "history-item-highlight"
) => {
const set = (obj: Record<string, any>, path: string, value: any) => {
const pathValue = path.split(".")
let i: number