Skip to content

Commit 5aa4aa3

Browse files
committed
chore: add group oriented autocomplete to SDK
1 parent 5bfb7f1 commit 5aa4aa3

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

clients/ts-sdk/package.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,25 @@
1717
"files": [
1818
"dist"
1919
],
20-
"version": "0.0.122",
20+
"version": "0.0.124",
2121
"license": "MIT",
22+
"description": "TypeScript SDK for Mintlify Search",
23+
"keywords": [
24+
"trieve",
25+
"sdk",
26+
"typescript",
27+
"search",
28+
"api"
29+
],
30+
"repository": {
31+
"type": "git",
32+
"url": "https://github.com/devflowinc/trieve.git",
33+
"directory": "clients/ts-sdk"
34+
},
35+
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/ts-sdk",
36+
"bugs": {
37+
"url": "https://github.com/devflowinc/trieve/issues"
38+
},
2239
"scripts": {
2340
"lint": "eslint 'src/**/*.ts'",
2441
"build:clean": "rm -f tsconfig.tsbuildinfo && rm -rf dist && yarn type:gen && yarn build",
@@ -41,4 +58,4 @@
4158
"typescript": "^5.5.4",
4259
"vitest": "^2.0.5"
4360
}
44-
}
61+
}

clients/ts-sdk/src/functions/groups/index.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import {
88
AddChunkToGroupReqPayload,
9+
AutocompleteSearchOverGroupsReqPayload,
910
CreateChunkGroupReqPayloadEnum,
1011
DeleteChunkGroupData,
1112
DeleteGroupByTrackingIdData,
@@ -540,3 +541,35 @@ export async function getGroupsForDataset(
540541
signal,
541542
);
542543
}
544+
545+
/**
546+
* Provides autocomplete suggestions for group-oriented searches. This function returns suggested completions based on partial queries that can be used to search over groups. Useful for implementing search-as-you-type functionality for group searches.
547+
*
548+
* Example:
549+
* ```js
550+
* const data = await trieve.groupOrientedAutcomplete({
551+
* query: "partial search ter",
552+
* size: 10,
553+
* });
554+
* ```
555+
*/
556+
export async function groupOrientedAutcomplete(
557+
/** @hidden */
558+
this: TrieveSDK,
559+
data: Omit<AutocompleteSearchOverGroupsReqPayload, "datasetId">,
560+
signal?: AbortSignal,
561+
) {
562+
if (!this.datasetId) {
563+
throw new Error("datasetId is required");
564+
}
565+
566+
return this.trieve.fetch(
567+
"/api/chunk_group/group_oriented_autocomplete",
568+
"post",
569+
{
570+
data,
571+
datasetId: this.datasetId,
572+
},
573+
signal,
574+
);
575+
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8363,6 +8363,11 @@ tr46@~0.0.3:
83638363
resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz"
83648364
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
83658365

8366+
trieve-ts-sdk@*:
8367+
version "0.0.122"
8368+
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.122.tgz#da07e5230c1827eee1cd8b970d60bd85bf104d4e"
8369+
integrity sha512-h0XEfjJQeaAtpjwKjYMh06Z/3p06l2dsW2vQ2MK7OIkQ9o6iNi1dwR0dtFOK+JtmZ6tPjDgP9O13UAZJ0R5y7g==
8370+
83668371
trieve-ts-sdk@^0.0.92:
83678372
version "0.0.92"
83688373
resolved "https://registry.npmjs.org/trieve-ts-sdk/-/trieve-ts-sdk-0.0.92.tgz"

0 commit comments

Comments
 (0)