* Query a vector collection
(collectionId, searchText, topK, threshold = 0.2)
| 427 | * Query a vector collection |
| 428 | */ |
| 429 | async function apiQueryCollection(collectionId, searchText, topK, threshold = 0.2) { |
| 430 | ensureVectorConfig(); |
| 431 | |
| 432 | const args = await getAdditionalVectorArgs([searchText]); |
| 433 | |
| 434 | const response = await fetch('/api/vector/query', { |
| 435 | method: 'POST', |
| 436 | headers: getRequestHeaders(), |
| 437 | credentials: 'same-origin', |
| 438 | body: JSON.stringify({ |
| 439 | ...getVectorsRequestBody(args), |
| 440 | collectionId: collectionId, |
| 441 | searchText: searchText, |
| 442 | topK: topK, |
| 443 | source: getVectorSettings().source, |
| 444 | threshold: threshold, |
| 445 | }), |
| 446 | }); |
| 447 | |
| 448 | if (!response.ok) { |
| 449 | throw new Error(`Failed to query collection ${collectionId}`); |
| 450 | } |
| 451 | |
| 452 | return await response.json(); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Delete specific hashes from a vector collection |
no test coverage detected