(params: {
queryVector: number[];
userId: string;
workspaceId: string;
threshold?: number;
limit?: number;
excludeIds?: string[];
})
| 490 | * Search for similar entities by vector similarity |
| 491 | */ |
| 492 | export async function searchEntities(params: { |
| 493 | queryVector: number[]; |
| 494 | userId: string; |
| 495 | workspaceId: string; |
| 496 | threshold?: number; |
| 497 | limit?: number; |
| 498 | excludeIds?: string[]; |
| 499 | }): Promise<Array<{ uuid: string; score: number }>> { |
| 500 | try { |
| 501 | const results = await vectorProvider().search({ |
| 502 | vector: params.queryVector, |
| 503 | namespace: VECTOR_NAMESPACES.ENTITY, |
| 504 | limit: params.limit || 10, |
| 505 | threshold: params.threshold || 0.5, |
| 506 | filter: { |
| 507 | userId: params.userId, |
| 508 | excludeIds: params.excludeIds, |
| 509 | workspaceId: params.workspaceId, |
| 510 | }, |
| 511 | }); |
| 512 | |
| 513 | return results.map((r) => ({ uuid: r.id, score: r.score })); |
| 514 | } catch (error) { |
| 515 | logger.error(`Failed to search entities:`, { error }); |
| 516 | throw error; |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Batch score statements against query vector |
nothing calls this directly
no test coverage detected