diff --git a/clients/ts-sdk/src/functions/analytics/analytics.test.ts b/clients/ts-sdk/src/functions/analytics/analytics.test.ts index 7ce737337..f33debc16 100644 --- a/clients/ts-sdk/src/functions/analytics/analytics.test.ts +++ b/clients/ts-sdk/src/functions/analytics/analytics.test.ts @@ -62,6 +62,15 @@ describe("Analytics Tests", async () => { expectTypeOf(data).toBeVoid(); }); + + test("rateSearchQuery", async () => { + const data = await trieve.rateSearchQuery({ + rating: 1, + query_id: "9892d267-3dc7-43b7-8fc2-700903baa217", + }); + + expectTypeOf(data).toBeVoid(); + }); test("getTopDatasets", async () => { const data = await trieve.getTopDatasets({ organizationId: "de73679c-707f-4fc2-853e-994c910d944c", diff --git a/clients/ts-sdk/src/functions/analytics/index.ts b/clients/ts-sdk/src/functions/analytics/index.ts index f6674e5ab..3414df450 100644 --- a/clients/ts-sdk/src/functions/analytics/index.ts +++ b/clients/ts-sdk/src/functions/analytics/index.ts @@ -250,6 +250,34 @@ export async function rateRagQuery( this: TrieveSDK, data: RateQueryRequest, signal?: AbortSignal +) { + return this.trieve.fetch( + "/api/analytics/rag", + "put", + { + data, + datasetId: this.datasetId, + }, + signal + ); +} + +/** + * Function that allows you to rate a search query. + * + * Example: + * ```js + *const data = await trieve.rateSearchQuery({ + query_id: 123, + rating: 1, +}); + * ``` + */ +export async function rateSearchQuery( + /** @hidden */ + this: TrieveSDK, + data: RateQueryRequest, + signal?: AbortSignal ) { return this.trieve.fetch( "/api/analytics/search",