Skip to content

Commit fd5f5d8

Browse files
authored
dataset fixes (#5525)
1 parent 4716472 commit fd5f5d8

File tree

8 files changed

+82
-53
lines changed

8 files changed

+82
-53
lines changed

bifrost/lib/clients/jawnTypes/private.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,10 +1790,6 @@ Json: JsonObject;
17901790
gt?: string;
17911791
};
17921792
/** @description Make all properties in T optional */
1793-
Partial_VectorOperators_: {
1794-
contains?: string;
1795-
};
1796-
/** @description Make all properties in T optional */
17971793
Partial_RequestResponseRMTToOperators_: {
17981794
country_code?: components["schemas"]["Partial_TextOperators_"];
17991795
latency?: components["schemas"]["Partial_NumberOperators_"];
@@ -1829,8 +1825,8 @@ Json: JsonObject;
18291825
[key: string]: components["schemas"]["Partial_TextOperators_"];
18301826
};
18311827
scores_column?: components["schemas"]["Partial_TextOperators_"];
1832-
request_body?: components["schemas"]["Partial_VectorOperators_"];
1833-
response_body?: components["schemas"]["Partial_VectorOperators_"];
1828+
request_body?: components["schemas"]["Partial_TextOperators_"];
1829+
response_body?: components["schemas"]["Partial_TextOperators_"];
18341830
cache_enabled?: components["schemas"]["Partial_BooleanOperators_"];
18351831
cache_reference_id?: components["schemas"]["Partial_TextOperators_"];
18361832
cached?: components["schemas"]["Partial_BooleanOperators_"];

bifrost/lib/clients/jawnTypes/public.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,6 @@ Json: JsonObject;
18711871
gt?: string;
18721872
};
18731873
/** @description Make all properties in T optional */
1874-
Partial_VectorOperators_: {
1875-
contains?: string;
1876-
};
1877-
/** @description Make all properties in T optional */
18781874
Partial_RequestResponseRMTToOperators_: {
18791875
country_code?: components["schemas"]["Partial_TextOperators_"];
18801876
latency?: components["schemas"]["Partial_NumberOperators_"];
@@ -1910,8 +1906,8 @@ Json: JsonObject;
19101906
[key: string]: components["schemas"]["Partial_TextOperators_"];
19111907
};
19121908
scores_column?: components["schemas"]["Partial_TextOperators_"];
1913-
request_body?: components["schemas"]["Partial_VectorOperators_"];
1914-
response_body?: components["schemas"]["Partial_VectorOperators_"];
1909+
request_body?: components["schemas"]["Partial_TextOperators_"];
1910+
response_body?: components["schemas"]["Partial_TextOperators_"];
19151911
cache_enabled?: components["schemas"]["Partial_BooleanOperators_"];
19161912
cache_reference_id?: components["schemas"]["Partial_TextOperators_"];
19171913
cached?: components["schemas"]["Partial_BooleanOperators_"];

docs/swagger.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4036,15 +4036,6 @@
40364036
"type": "object",
40374037
"description": "Make all properties in T optional"
40384038
},
4039-
"Partial_VectorOperators_": {
4040-
"properties": {
4041-
"contains": {
4042-
"type": "string"
4043-
}
4044-
},
4045-
"type": "object",
4046-
"description": "Make all properties in T optional"
4047-
},
40484039
"Partial_RequestResponseRMTToOperators_": {
40494040
"properties": {
40504041
"country_code": {
@@ -4146,10 +4137,10 @@
41464137
"$ref": "#/components/schemas/Partial_TextOperators_"
41474138
},
41484139
"request_body": {
4149-
"$ref": "#/components/schemas/Partial_VectorOperators_"
4140+
"$ref": "#/components/schemas/Partial_TextOperators_"
41504141
},
41514142
"response_body": {
4152-
"$ref": "#/components/schemas/Partial_VectorOperators_"
4143+
"$ref": "#/components/schemas/Partial_TextOperators_"
41534144
},
41544145
"cache_enabled": {
41554146
"$ref": "#/components/schemas/Partial_BooleanOperators_"

helicone-mcp/src/types/public.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,6 @@ Json: JsonObject;
18711871
gt?: string;
18721872
};
18731873
/** @description Make all properties in T optional */
1874-
Partial_VectorOperators_: {
1875-
contains?: string;
1876-
};
1877-
/** @description Make all properties in T optional */
18781874
Partial_RequestResponseRMTToOperators_: {
18791875
country_code?: components["schemas"]["Partial_TextOperators_"];
18801876
latency?: components["schemas"]["Partial_NumberOperators_"];
@@ -1910,8 +1906,8 @@ Json: JsonObject;
19101906
[key: string]: components["schemas"]["Partial_TextOperators_"];
19111907
};
19121908
scores_column?: components["schemas"]["Partial_TextOperators_"];
1913-
request_body?: components["schemas"]["Partial_VectorOperators_"];
1914-
response_body?: components["schemas"]["Partial_VectorOperators_"];
1909+
request_body?: components["schemas"]["Partial_TextOperators_"];
1910+
response_body?: components["schemas"]["Partial_TextOperators_"];
19151911
cache_enabled?: components["schemas"]["Partial_BooleanOperators_"];
19161912
cache_reference_id?: components["schemas"]["Partial_TextOperators_"];
19171913
cached?: components["schemas"]["Partial_BooleanOperators_"];

valhalla/jawn/src/managers/dataset/HeliconeDatasetManager.ts

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Json } from "../../lib/db/database.types";
22
import { AuthParams } from "../../packages/common/auth/types";
3-
import { dbExecute } from "../../lib/shared/db/dbExecute";
3+
import { dbExecute, dbQueryClickhouse } from "../../lib/shared/db/dbExecute";
44
import { S3Client } from "../../lib/shared/db/s3Client";
55
import {
66
Result,
@@ -243,7 +243,20 @@ export class HeliconeDatasetManager extends BaseManager {
243243
row.id,
244244
this.authParams.organizationId
245245
);
246-
return await this.s3Client.copyObject(key, newKey);
246+
247+
// Try to copy from S3 first
248+
const copyResult = await this.s3Client.copyObject(key, newKey);
249+
250+
// If copy fails (e.g., source doesn't exist), try to fetch from ClickHouse and store directly
251+
if (copyResult.error) {
252+
const fallbackResult = await this.fetchAndStoreRequestBody(
253+
row.origin_request_id,
254+
newKey
255+
);
256+
return fallbackResult;
257+
}
258+
259+
return copyResult;
247260
})
248261
);
249262

@@ -257,6 +270,57 @@ export class HeliconeDatasetManager extends BaseManager {
257270
}
258271
}
259272

273+
/**
274+
* Fetches request/response body from ClickHouse and stores it in S3
275+
* Used as a fallback when the source S3 object doesn't exist
276+
*/
277+
private async fetchAndStoreRequestBody(
278+
requestId: string,
279+
destinationKey: string
280+
): Promise<Result<string, string>> {
281+
try {
282+
// Fetch the request/response body from ClickHouse
283+
const query = `
284+
SELECT
285+
request_body,
286+
response_body
287+
FROM request_response_rmt
288+
WHERE request_id = {val_0: String}
289+
AND organization_id = {val_1: String}
290+
LIMIT 1
291+
`;
292+
293+
const result = await dbQueryClickhouse<{
294+
request_body: string;
295+
response_body: string;
296+
}>(query, [requestId, this.authParams.organizationId]);
297+
298+
if (result.error || !result.data || result.data.length === 0) {
299+
return err(
300+
`Request body not found in ClickHouse for request ${requestId}`
301+
);
302+
}
303+
304+
const { request_body, response_body } = result.data[0];
305+
306+
// Store the body in S3 at the dataset location
307+
const bodyData = JSON.stringify({
308+
request: request_body ? JSON.parse(request_body) : {},
309+
response: response_body ? JSON.parse(response_body) : {},
310+
});
311+
312+
const storeResult = await this.s3Client.store(destinationKey, bodyData);
313+
314+
if (storeResult.error) {
315+
return err(`Failed to store request body: ${storeResult.error}`);
316+
}
317+
318+
return ok("Success");
319+
} catch (error) {
320+
return err(`Failed to fetch and store request body: ${error}`);
321+
}
322+
}
323+
260324
private async removeRequests(
261325
datasetId: string,
262326
removeRequests: string[]

web/lib/clients/jawnTypes/private.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,10 +1790,6 @@ Json: JsonObject;
17901790
gt?: string;
17911791
};
17921792
/** @description Make all properties in T optional */
1793-
Partial_VectorOperators_: {
1794-
contains?: string;
1795-
};
1796-
/** @description Make all properties in T optional */
17971793
Partial_RequestResponseRMTToOperators_: {
17981794
country_code?: components["schemas"]["Partial_TextOperators_"];
17991795
latency?: components["schemas"]["Partial_NumberOperators_"];
@@ -1829,8 +1825,8 @@ Json: JsonObject;
18291825
[key: string]: components["schemas"]["Partial_TextOperators_"];
18301826
};
18311827
scores_column?: components["schemas"]["Partial_TextOperators_"];
1832-
request_body?: components["schemas"]["Partial_VectorOperators_"];
1833-
response_body?: components["schemas"]["Partial_VectorOperators_"];
1828+
request_body?: components["schemas"]["Partial_TextOperators_"];
1829+
response_body?: components["schemas"]["Partial_TextOperators_"];
18341830
cache_enabled?: components["schemas"]["Partial_BooleanOperators_"];
18351831
cache_reference_id?: components["schemas"]["Partial_TextOperators_"];
18361832
cached?: components["schemas"]["Partial_BooleanOperators_"];

web/lib/clients/jawnTypes/public.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,10 +1871,6 @@ Json: JsonObject;
18711871
gt?: string;
18721872
};
18731873
/** @description Make all properties in T optional */
1874-
Partial_VectorOperators_: {
1875-
contains?: string;
1876-
};
1877-
/** @description Make all properties in T optional */
18781874
Partial_RequestResponseRMTToOperators_: {
18791875
country_code?: components["schemas"]["Partial_TextOperators_"];
18801876
latency?: components["schemas"]["Partial_NumberOperators_"];
@@ -1910,8 +1906,8 @@ Json: JsonObject;
19101906
[key: string]: components["schemas"]["Partial_TextOperators_"];
19111907
};
19121908
scores_column?: components["schemas"]["Partial_TextOperators_"];
1913-
request_body?: components["schemas"]["Partial_VectorOperators_"];
1914-
response_body?: components["schemas"]["Partial_VectorOperators_"];
1909+
request_body?: components["schemas"]["Partial_TextOperators_"];
1910+
response_body?: components["schemas"]["Partial_TextOperators_"];
19151911
cache_enabled?: components["schemas"]["Partial_BooleanOperators_"];
19161912
cache_reference_id?: components["schemas"]["Partial_TextOperators_"];
19171913
cached?: components["schemas"]["Partial_BooleanOperators_"];

web/lib/freeTierLimits.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,15 @@ export const FREE_TIER_CONFIG: FreeTierConfig = {
9292
},
9393
datasets: {
9494
main: {
95-
getLimit: () => 1,
96-
description: (limit) =>
97-
`You can create up to ${limit} datasets with the free tier`,
95+
getLimit: () => Infinity, // Unlimited datasets for free tier
96+
description: () => `Unlimited datasets`,
9897
upgradeFeatureName: FEATURE_DISPLAY_NAMES.datasets,
99-
upgradeMessage: (limit, used) =>
100-
`You've used ${used}/${limit} datasets. Upgrade for unlimited access.`,
10198
},
10299
subfeatures: {
103100
requests: {
104-
getLimit: () => 10,
105-
description: (limit) =>
106-
`You can add up to ${limit} requests per dataset with the free tier`,
101+
getLimit: () => Infinity, // Unlimited requests per dataset for free tier
102+
description: () => `Unlimited requests per dataset`,
107103
upgradeFeatureName: FEATURE_DISPLAY_NAMES.datasets,
108-
upgradeMessage: (limit, used) =>
109-
`You've selected ${used}/${limit} requests. Upgrade to add more requests per dataset.`,
110104
},
111105
},
112106
},

0 commit comments

Comments
 (0)