forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemoryCategory.ts
More file actions
37 lines (35 loc) · 1.12 KB
/
Copy pathmemoryCategory.ts
File metadata and controls
37 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { Memory, MemoryCategory } from '@/types/conversation';
/**
* Normalize a memory's raw category to one of the product categories.
*
* Ported from the Electron desktop app
* (`desktop/windows/src/renderer/src/lib/memoryFilters.ts`): anything
* unrecognized or absent reads as `interesting`, matching the backend's own
* "unknown → interesting" default so the two never disagree.
*/
export function categoryOf(memory: Pick<Memory, 'category'>): MemoryCategory {
const category = memory.category;
if (
category === 'manual' ||
category === 'system' ||
category === 'interesting' ||
category === 'workflow'
) {
return category;
}
return 'interesting';
}
/**
* Client-side category filter.
*
* `/v3/memories` takes no `categories` parameter — FastAPI drops the unknown
* query param — so category selection has to be applied here, the same way
* desktop does it.
*/
export function matchesCategories(
memory: Pick<Memory, 'category'>,
categories: readonly MemoryCategory[],
): boolean {
if (categories.length === 0) return true;
return categories.includes(categoryOf(memory));
}