Skip to content

Commit

Permalink
cleanup: add omitCredentials option + make datasetId optional in ts-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev committed Dec 19, 2024
1 parent a7f7919 commit dc07d33
Show file tree
Hide file tree
Showing 9 changed files with 295 additions and 38 deletions.
2 changes: 1 addition & 1 deletion clients/search-component/src/utils/trieve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export const getAllChunksForGroup = async (
"/api/chunk_group/{group_id}/{page}",
"get",
{
datasetId: trieve.datasetId,
datasetId: trieve.datasetId as string,
groupId,
page,
}
Expand Down
72 changes: 52 additions & 20 deletions clients/ts-sdk/src/functions/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,20 @@ export async function getCTRAnalytics(
/** @hidden */
this: TrieveSDK,
data: CTRAnalytics,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return await this.trieve.fetch(
"/api/analytics/events/ctr",
"post",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand All @@ -71,16 +75,20 @@ export async function sendCTRAnalytics(
/** @hidden */
this: TrieveSDK,
data: CTRDataRequestBody,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return await this.trieve.fetch(
"/api/analytics/ctr",
"put",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand Down Expand Up @@ -110,16 +118,20 @@ export async function getRagAnalytics(
/** @hidden */
this: TrieveSDK,
data: RAGAnalytics,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/rag",
"post",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand Down Expand Up @@ -148,16 +160,20 @@ export async function getRecommendationAnalytics(
/** @hidden */
this: TrieveSDK,
data: RecommendationAnalytics,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/recommendations",
"post",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand Down Expand Up @@ -186,16 +202,20 @@ export async function getSearchAnalytics(
/** @hidden */
this: TrieveSDK,
data: SearchAnalytics,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/search",
"post",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand All @@ -221,16 +241,20 @@ export async function getClusterAnalytics(
/** @hidden */
this: TrieveSDK,
data: ClusterAnalytics,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/search/cluster",
"post",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand All @@ -249,16 +273,20 @@ export async function rateRagQuery(
/** @hidden */
this: TrieveSDK,
data: RateQueryRequest,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/rag",
"put",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand All @@ -277,16 +305,20 @@ export async function rateSearchQuery(
/** @hidden */
this: TrieveSDK,
data: RateQueryRequest,
signal?: AbortSignal,
signal?: AbortSignal
) {
if (!this.datasetId) {
throw new Error("datasetId is required");
}

return this.trieve.fetch(
"/api/analytics/search",
"put",
{
data,
datasetId: this.datasetId,
},
signal,
signal
);
}

Expand All @@ -305,7 +337,7 @@ export async function getTopDatasets(
/** @hidden */
this: TrieveSDK,
data: GetTopDatasetsRequestBody & { organizationId: string },
signal?: AbortSignal,
signal?: AbortSignal
) {
return this.trieve.fetch(
"/api/analytics/top",
Expand All @@ -314,7 +346,7 @@ export async function getTopDatasets(
data,
organizationId: data.organizationId,
},
signal,
signal
);
}

Expand All @@ -341,14 +373,14 @@ export async function getAllAnalyticsEvents(
/** @hidden */
this: TrieveSDK,
data: GetEventsRequestBody,
signal?: AbortSignal,
signal?: AbortSignal
) {
return await this.trieve.fetch(
"/api/analytics/events/all",
"post",
{
data,
},
signal,
signal
);
}
Loading

0 comments on commit dc07d33

Please sign in to comment.