braintrust 0.0.179 → 0.0.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.mts +31 -1
- package/dist/browser.d.ts +31 -1
- package/dist/browser.js +21 -17
- package/dist/browser.mjs +21 -17
- package/dist/cli.js +23 -19
- package/dist/index.d.mts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +21 -17
- package/dist/index.mjs +21 -17
- package/package.json +2 -2
package/dist/browser.d.mts
CHANGED
|
@@ -521,6 +521,32 @@ declare class Attachment {
|
|
|
521
521
|
private initUploader;
|
|
522
522
|
private initData;
|
|
523
523
|
}
|
|
524
|
+
declare const attachmentMetadataSchema: z.ZodObject<{
|
|
525
|
+
downloadUrl: z.ZodString;
|
|
526
|
+
status: z.ZodObject<{
|
|
527
|
+
upload_status: z.ZodEnum<["uploading", "done", "error"]>;
|
|
528
|
+
error_message: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
529
|
+
}, "strip", z.ZodTypeAny, {
|
|
530
|
+
upload_status: "error" | "done" | "uploading";
|
|
531
|
+
error_message?: string | undefined;
|
|
532
|
+
}, {
|
|
533
|
+
upload_status: "error" | "done" | "uploading";
|
|
534
|
+
error_message?: string | null | undefined;
|
|
535
|
+
}>;
|
|
536
|
+
}, "strip", z.ZodTypeAny, {
|
|
537
|
+
status: {
|
|
538
|
+
upload_status: "error" | "done" | "uploading";
|
|
539
|
+
error_message?: string | undefined;
|
|
540
|
+
};
|
|
541
|
+
downloadUrl: string;
|
|
542
|
+
}, {
|
|
543
|
+
status: {
|
|
544
|
+
upload_status: "error" | "done" | "uploading";
|
|
545
|
+
error_message?: string | null | undefined;
|
|
546
|
+
};
|
|
547
|
+
downloadUrl: string;
|
|
548
|
+
}>;
|
|
549
|
+
type AttachmentMetadata = z.infer<typeof attachmentMetadataSchema>;
|
|
524
550
|
/**
|
|
525
551
|
* A readonly alternative to `Attachment`, which can be used for fetching
|
|
526
552
|
* already-uploaded Attachments.
|
|
@@ -546,13 +572,17 @@ declare class ReadonlyAttachment {
|
|
|
546
572
|
* contents from the object store on first access.
|
|
547
573
|
*/
|
|
548
574
|
data(): Promise<Blob>;
|
|
575
|
+
/**
|
|
576
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
577
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
578
|
+
*/
|
|
579
|
+
metadata(): Promise<AttachmentMetadata>;
|
|
549
580
|
/**
|
|
550
581
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
551
582
|
* in case it changes over time.
|
|
552
583
|
*/
|
|
553
584
|
status(): Promise<AttachmentStatus>;
|
|
554
585
|
private initDownloader;
|
|
555
|
-
private fetchMetadata;
|
|
556
586
|
}
|
|
557
587
|
/**
|
|
558
588
|
* Update a span using the output of `span.export()`. It is important that you only resume updating
|
package/dist/browser.d.ts
CHANGED
|
@@ -521,6 +521,32 @@ declare class Attachment {
|
|
|
521
521
|
private initUploader;
|
|
522
522
|
private initData;
|
|
523
523
|
}
|
|
524
|
+
declare const attachmentMetadataSchema: z.ZodObject<{
|
|
525
|
+
downloadUrl: z.ZodString;
|
|
526
|
+
status: z.ZodObject<{
|
|
527
|
+
upload_status: z.ZodEnum<["uploading", "done", "error"]>;
|
|
528
|
+
error_message: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
529
|
+
}, "strip", z.ZodTypeAny, {
|
|
530
|
+
upload_status: "error" | "done" | "uploading";
|
|
531
|
+
error_message?: string | undefined;
|
|
532
|
+
}, {
|
|
533
|
+
upload_status: "error" | "done" | "uploading";
|
|
534
|
+
error_message?: string | null | undefined;
|
|
535
|
+
}>;
|
|
536
|
+
}, "strip", z.ZodTypeAny, {
|
|
537
|
+
status: {
|
|
538
|
+
upload_status: "error" | "done" | "uploading";
|
|
539
|
+
error_message?: string | undefined;
|
|
540
|
+
};
|
|
541
|
+
downloadUrl: string;
|
|
542
|
+
}, {
|
|
543
|
+
status: {
|
|
544
|
+
upload_status: "error" | "done" | "uploading";
|
|
545
|
+
error_message?: string | null | undefined;
|
|
546
|
+
};
|
|
547
|
+
downloadUrl: string;
|
|
548
|
+
}>;
|
|
549
|
+
type AttachmentMetadata = z.infer<typeof attachmentMetadataSchema>;
|
|
524
550
|
/**
|
|
525
551
|
* A readonly alternative to `Attachment`, which can be used for fetching
|
|
526
552
|
* already-uploaded Attachments.
|
|
@@ -546,13 +572,17 @@ declare class ReadonlyAttachment {
|
|
|
546
572
|
* contents from the object store on first access.
|
|
547
573
|
*/
|
|
548
574
|
data(): Promise<Blob>;
|
|
575
|
+
/**
|
|
576
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
577
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
578
|
+
*/
|
|
579
|
+
metadata(): Promise<AttachmentMetadata>;
|
|
549
580
|
/**
|
|
550
581
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
551
582
|
* in case it changes over time.
|
|
552
583
|
*/
|
|
553
584
|
status(): Promise<AttachmentStatus>;
|
|
554
585
|
private initDownloader;
|
|
555
|
-
private fetchMetadata;
|
|
556
586
|
}
|
|
557
587
|
/**
|
|
558
588
|
* Update a span using the output of `span.export()`. It is important that you only resume updating
|
package/dist/browser.js
CHANGED
|
@@ -1189,16 +1189,35 @@ var ReadonlyAttachment = class {
|
|
|
1189
1189
|
async data() {
|
|
1190
1190
|
return this._data.get();
|
|
1191
1191
|
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
1194
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
1195
|
+
*/
|
|
1196
|
+
async metadata() {
|
|
1197
|
+
const state = this.state ?? _globalState;
|
|
1198
|
+
await state.login({});
|
|
1199
|
+
const resp = await state.apiConn().get("/attachment", {
|
|
1200
|
+
key: this.reference.key,
|
|
1201
|
+
filename: this.reference.filename,
|
|
1202
|
+
content_type: this.reference.content_type,
|
|
1203
|
+
org_id: state.orgId || ""
|
|
1204
|
+
});
|
|
1205
|
+
if (!resp.ok) {
|
|
1206
|
+
const errorStr = JSON.stringify(resp);
|
|
1207
|
+
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1208
|
+
}
|
|
1209
|
+
return attachmentMetadataSchema.parse(await resp.json());
|
|
1210
|
+
}
|
|
1192
1211
|
/**
|
|
1193
1212
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
1194
1213
|
* in case it changes over time.
|
|
1195
1214
|
*/
|
|
1196
1215
|
async status() {
|
|
1197
|
-
return (await this.
|
|
1216
|
+
return (await this.metadata()).status;
|
|
1198
1217
|
}
|
|
1199
1218
|
initDownloader() {
|
|
1200
1219
|
const download = async () => {
|
|
1201
|
-
const { downloadUrl, status } = await this.
|
|
1220
|
+
const { downloadUrl, status } = await this.metadata();
|
|
1202
1221
|
if (status.upload_status !== "done") {
|
|
1203
1222
|
throw new Error(
|
|
1204
1223
|
`Expected attachment status "done", got "${status.upload_status}"`
|
|
@@ -1213,21 +1232,6 @@ var ReadonlyAttachment = class {
|
|
|
1213
1232
|
};
|
|
1214
1233
|
return new LazyValue(download);
|
|
1215
1234
|
}
|
|
1216
|
-
async fetchMetadata() {
|
|
1217
|
-
const state = this.state ?? _globalState;
|
|
1218
|
-
await state.login({});
|
|
1219
|
-
const resp = await state.apiConn().get("/attachment", {
|
|
1220
|
-
key: this.reference.key,
|
|
1221
|
-
filename: this.reference.filename,
|
|
1222
|
-
content_type: this.reference.content_type,
|
|
1223
|
-
org_id: state.orgId || ""
|
|
1224
|
-
});
|
|
1225
|
-
if (!resp.ok) {
|
|
1226
|
-
const errorStr = JSON.stringify(resp);
|
|
1227
|
-
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1228
|
-
}
|
|
1229
|
-
return attachmentMetadataSchema.parse(await resp.json());
|
|
1230
|
-
}
|
|
1231
1235
|
};
|
|
1232
1236
|
function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
1233
1237
|
id,
|
package/dist/browser.mjs
CHANGED
|
@@ -1137,16 +1137,35 @@ var ReadonlyAttachment = class {
|
|
|
1137
1137
|
async data() {
|
|
1138
1138
|
return this._data.get();
|
|
1139
1139
|
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
1142
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
1143
|
+
*/
|
|
1144
|
+
async metadata() {
|
|
1145
|
+
const state = this.state ?? _globalState;
|
|
1146
|
+
await state.login({});
|
|
1147
|
+
const resp = await state.apiConn().get("/attachment", {
|
|
1148
|
+
key: this.reference.key,
|
|
1149
|
+
filename: this.reference.filename,
|
|
1150
|
+
content_type: this.reference.content_type,
|
|
1151
|
+
org_id: state.orgId || ""
|
|
1152
|
+
});
|
|
1153
|
+
if (!resp.ok) {
|
|
1154
|
+
const errorStr = JSON.stringify(resp);
|
|
1155
|
+
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1156
|
+
}
|
|
1157
|
+
return attachmentMetadataSchema.parse(await resp.json());
|
|
1158
|
+
}
|
|
1140
1159
|
/**
|
|
1141
1160
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
1142
1161
|
* in case it changes over time.
|
|
1143
1162
|
*/
|
|
1144
1163
|
async status() {
|
|
1145
|
-
return (await this.
|
|
1164
|
+
return (await this.metadata()).status;
|
|
1146
1165
|
}
|
|
1147
1166
|
initDownloader() {
|
|
1148
1167
|
const download = async () => {
|
|
1149
|
-
const { downloadUrl, status } = await this.
|
|
1168
|
+
const { downloadUrl, status } = await this.metadata();
|
|
1150
1169
|
if (status.upload_status !== "done") {
|
|
1151
1170
|
throw new Error(
|
|
1152
1171
|
`Expected attachment status "done", got "${status.upload_status}"`
|
|
@@ -1161,21 +1180,6 @@ var ReadonlyAttachment = class {
|
|
|
1161
1180
|
};
|
|
1162
1181
|
return new LazyValue(download);
|
|
1163
1182
|
}
|
|
1164
|
-
async fetchMetadata() {
|
|
1165
|
-
const state = this.state ?? _globalState;
|
|
1166
|
-
await state.login({});
|
|
1167
|
-
const resp = await state.apiConn().get("/attachment", {
|
|
1168
|
-
key: this.reference.key,
|
|
1169
|
-
filename: this.reference.filename,
|
|
1170
|
-
content_type: this.reference.content_type,
|
|
1171
|
-
org_id: state.orgId || ""
|
|
1172
|
-
});
|
|
1173
|
-
if (!resp.ok) {
|
|
1174
|
-
const errorStr = JSON.stringify(resp);
|
|
1175
|
-
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1176
|
-
}
|
|
1177
|
-
return attachmentMetadataSchema.parse(await resp.json());
|
|
1178
|
-
}
|
|
1179
1183
|
};
|
|
1180
1184
|
function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
1181
1185
|
id,
|
package/dist/cli.js
CHANGED
|
@@ -1236,7 +1236,7 @@ var require_package = __commonJS({
|
|
|
1236
1236
|
"package.json"(exports2, module2) {
|
|
1237
1237
|
module2.exports = {
|
|
1238
1238
|
name: "braintrust",
|
|
1239
|
-
version: "0.0.
|
|
1239
|
+
version: "0.0.181",
|
|
1240
1240
|
description: "SDK for integrating Braintrust",
|
|
1241
1241
|
repository: {
|
|
1242
1242
|
type: "git",
|
|
@@ -1311,7 +1311,7 @@ var require_package = __commonJS({
|
|
|
1311
1311
|
},
|
|
1312
1312
|
dependencies: {
|
|
1313
1313
|
"@ai-sdk/provider": "^1.0.1",
|
|
1314
|
-
"@braintrust/core": "0.0.
|
|
1314
|
+
"@braintrust/core": "0.0.75",
|
|
1315
1315
|
"@next/env": "^14.2.3",
|
|
1316
1316
|
"@vercel/functions": "^1.0.2",
|
|
1317
1317
|
ai: "^3.2.16",
|
|
@@ -2457,16 +2457,35 @@ var ReadonlyAttachment = class {
|
|
|
2457
2457
|
async data() {
|
|
2458
2458
|
return this._data.get();
|
|
2459
2459
|
}
|
|
2460
|
+
/**
|
|
2461
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
2462
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
2463
|
+
*/
|
|
2464
|
+
async metadata() {
|
|
2465
|
+
const state = this.state ?? _globalState;
|
|
2466
|
+
await state.login({});
|
|
2467
|
+
const resp = await state.apiConn().get("/attachment", {
|
|
2468
|
+
key: this.reference.key,
|
|
2469
|
+
filename: this.reference.filename,
|
|
2470
|
+
content_type: this.reference.content_type,
|
|
2471
|
+
org_id: state.orgId || ""
|
|
2472
|
+
});
|
|
2473
|
+
if (!resp.ok) {
|
|
2474
|
+
const errorStr = JSON.stringify(resp);
|
|
2475
|
+
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
2476
|
+
}
|
|
2477
|
+
return attachmentMetadataSchema.parse(await resp.json());
|
|
2478
|
+
}
|
|
2460
2479
|
/**
|
|
2461
2480
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
2462
2481
|
* in case it changes over time.
|
|
2463
2482
|
*/
|
|
2464
2483
|
async status() {
|
|
2465
|
-
return (await this.
|
|
2484
|
+
return (await this.metadata()).status;
|
|
2466
2485
|
}
|
|
2467
2486
|
initDownloader() {
|
|
2468
2487
|
const download = async () => {
|
|
2469
|
-
const { downloadUrl, status } = await this.
|
|
2488
|
+
const { downloadUrl, status } = await this.metadata();
|
|
2470
2489
|
if (status.upload_status !== "done") {
|
|
2471
2490
|
throw new Error(
|
|
2472
2491
|
`Expected attachment status "done", got "${status.upload_status}"`
|
|
@@ -2481,21 +2500,6 @@ var ReadonlyAttachment = class {
|
|
|
2481
2500
|
};
|
|
2482
2501
|
return new LazyValue(download);
|
|
2483
2502
|
}
|
|
2484
|
-
async fetchMetadata() {
|
|
2485
|
-
const state = this.state ?? _globalState;
|
|
2486
|
-
await state.login({});
|
|
2487
|
-
const resp = await state.apiConn().get("/attachment", {
|
|
2488
|
-
key: this.reference.key,
|
|
2489
|
-
filename: this.reference.filename,
|
|
2490
|
-
content_type: this.reference.content_type,
|
|
2491
|
-
org_id: state.orgId || ""
|
|
2492
|
-
});
|
|
2493
|
-
if (!resp.ok) {
|
|
2494
|
-
const errorStr = JSON.stringify(resp);
|
|
2495
|
-
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
2496
|
-
}
|
|
2497
|
-
return attachmentMetadataSchema.parse(await resp.json());
|
|
2498
|
-
}
|
|
2499
2503
|
};
|
|
2500
2504
|
function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
2501
2505
|
id,
|
package/dist/index.d.mts
CHANGED
|
@@ -523,6 +523,32 @@ declare class Attachment {
|
|
|
523
523
|
private initUploader;
|
|
524
524
|
private initData;
|
|
525
525
|
}
|
|
526
|
+
declare const attachmentMetadataSchema: z.ZodObject<{
|
|
527
|
+
downloadUrl: z.ZodString;
|
|
528
|
+
status: z.ZodObject<{
|
|
529
|
+
upload_status: z.ZodEnum<["uploading", "done", "error"]>;
|
|
530
|
+
error_message: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
531
|
+
}, "strip", z.ZodTypeAny, {
|
|
532
|
+
upload_status: "error" | "done" | "uploading";
|
|
533
|
+
error_message?: string | undefined;
|
|
534
|
+
}, {
|
|
535
|
+
upload_status: "error" | "done" | "uploading";
|
|
536
|
+
error_message?: string | null | undefined;
|
|
537
|
+
}>;
|
|
538
|
+
}, "strip", z.ZodTypeAny, {
|
|
539
|
+
status: {
|
|
540
|
+
upload_status: "error" | "done" | "uploading";
|
|
541
|
+
error_message?: string | undefined;
|
|
542
|
+
};
|
|
543
|
+
downloadUrl: string;
|
|
544
|
+
}, {
|
|
545
|
+
status: {
|
|
546
|
+
upload_status: "error" | "done" | "uploading";
|
|
547
|
+
error_message?: string | null | undefined;
|
|
548
|
+
};
|
|
549
|
+
downloadUrl: string;
|
|
550
|
+
}>;
|
|
551
|
+
type AttachmentMetadata = z.infer<typeof attachmentMetadataSchema>;
|
|
526
552
|
/**
|
|
527
553
|
* A readonly alternative to `Attachment`, which can be used for fetching
|
|
528
554
|
* already-uploaded Attachments.
|
|
@@ -548,13 +574,17 @@ declare class ReadonlyAttachment {
|
|
|
548
574
|
* contents from the object store on first access.
|
|
549
575
|
*/
|
|
550
576
|
data(): Promise<Blob>;
|
|
577
|
+
/**
|
|
578
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
579
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
580
|
+
*/
|
|
581
|
+
metadata(): Promise<AttachmentMetadata>;
|
|
551
582
|
/**
|
|
552
583
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
553
584
|
* in case it changes over time.
|
|
554
585
|
*/
|
|
555
586
|
status(): Promise<AttachmentStatus>;
|
|
556
587
|
private initDownloader;
|
|
557
|
-
private fetchMetadata;
|
|
558
588
|
}
|
|
559
589
|
/**
|
|
560
590
|
* Update a span using the output of `span.export()`. It is important that you only resume updating
|
package/dist/index.d.ts
CHANGED
|
@@ -523,6 +523,32 @@ declare class Attachment {
|
|
|
523
523
|
private initUploader;
|
|
524
524
|
private initData;
|
|
525
525
|
}
|
|
526
|
+
declare const attachmentMetadataSchema: z.ZodObject<{
|
|
527
|
+
downloadUrl: z.ZodString;
|
|
528
|
+
status: z.ZodObject<{
|
|
529
|
+
upload_status: z.ZodEnum<["uploading", "done", "error"]>;
|
|
530
|
+
error_message: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodString>>, string | undefined, string | null | undefined>;
|
|
531
|
+
}, "strip", z.ZodTypeAny, {
|
|
532
|
+
upload_status: "error" | "done" | "uploading";
|
|
533
|
+
error_message?: string | undefined;
|
|
534
|
+
}, {
|
|
535
|
+
upload_status: "error" | "done" | "uploading";
|
|
536
|
+
error_message?: string | null | undefined;
|
|
537
|
+
}>;
|
|
538
|
+
}, "strip", z.ZodTypeAny, {
|
|
539
|
+
status: {
|
|
540
|
+
upload_status: "error" | "done" | "uploading";
|
|
541
|
+
error_message?: string | undefined;
|
|
542
|
+
};
|
|
543
|
+
downloadUrl: string;
|
|
544
|
+
}, {
|
|
545
|
+
status: {
|
|
546
|
+
upload_status: "error" | "done" | "uploading";
|
|
547
|
+
error_message?: string | null | undefined;
|
|
548
|
+
};
|
|
549
|
+
downloadUrl: string;
|
|
550
|
+
}>;
|
|
551
|
+
type AttachmentMetadata = z.infer<typeof attachmentMetadataSchema>;
|
|
526
552
|
/**
|
|
527
553
|
* A readonly alternative to `Attachment`, which can be used for fetching
|
|
528
554
|
* already-uploaded Attachments.
|
|
@@ -548,13 +574,17 @@ declare class ReadonlyAttachment {
|
|
|
548
574
|
* contents from the object store on first access.
|
|
549
575
|
*/
|
|
550
576
|
data(): Promise<Blob>;
|
|
577
|
+
/**
|
|
578
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
579
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
580
|
+
*/
|
|
581
|
+
metadata(): Promise<AttachmentMetadata>;
|
|
551
582
|
/**
|
|
552
583
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
553
584
|
* in case it changes over time.
|
|
554
585
|
*/
|
|
555
586
|
status(): Promise<AttachmentStatus>;
|
|
556
587
|
private initDownloader;
|
|
557
|
-
private fetchMetadata;
|
|
558
588
|
}
|
|
559
589
|
/**
|
|
560
590
|
* Update a span using the output of `span.export()`. It is important that you only resume updating
|
package/dist/index.js
CHANGED
|
@@ -1425,16 +1425,35 @@ var ReadonlyAttachment = class {
|
|
|
1425
1425
|
async data() {
|
|
1426
1426
|
return this._data.get();
|
|
1427
1427
|
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
1430
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
1431
|
+
*/
|
|
1432
|
+
async metadata() {
|
|
1433
|
+
const state = this.state ?? _globalState;
|
|
1434
|
+
await state.login({});
|
|
1435
|
+
const resp = await state.apiConn().get("/attachment", {
|
|
1436
|
+
key: this.reference.key,
|
|
1437
|
+
filename: this.reference.filename,
|
|
1438
|
+
content_type: this.reference.content_type,
|
|
1439
|
+
org_id: state.orgId || ""
|
|
1440
|
+
});
|
|
1441
|
+
if (!resp.ok) {
|
|
1442
|
+
const errorStr = JSON.stringify(resp);
|
|
1443
|
+
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1444
|
+
}
|
|
1445
|
+
return attachmentMetadataSchema.parse(await resp.json());
|
|
1446
|
+
}
|
|
1428
1447
|
/**
|
|
1429
1448
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
1430
1449
|
* in case it changes over time.
|
|
1431
1450
|
*/
|
|
1432
1451
|
async status() {
|
|
1433
|
-
return (await this.
|
|
1452
|
+
return (await this.metadata()).status;
|
|
1434
1453
|
}
|
|
1435
1454
|
initDownloader() {
|
|
1436
1455
|
const download = async () => {
|
|
1437
|
-
const { downloadUrl, status } = await this.
|
|
1456
|
+
const { downloadUrl, status } = await this.metadata();
|
|
1438
1457
|
if (status.upload_status !== "done") {
|
|
1439
1458
|
throw new Error(
|
|
1440
1459
|
`Expected attachment status "done", got "${status.upload_status}"`
|
|
@@ -1449,21 +1468,6 @@ var ReadonlyAttachment = class {
|
|
|
1449
1468
|
};
|
|
1450
1469
|
return new LazyValue(download);
|
|
1451
1470
|
}
|
|
1452
|
-
async fetchMetadata() {
|
|
1453
|
-
const state = this.state ?? _globalState;
|
|
1454
|
-
await state.login({});
|
|
1455
|
-
const resp = await state.apiConn().get("/attachment", {
|
|
1456
|
-
key: this.reference.key,
|
|
1457
|
-
filename: this.reference.filename,
|
|
1458
|
-
content_type: this.reference.content_type,
|
|
1459
|
-
org_id: state.orgId || ""
|
|
1460
|
-
});
|
|
1461
|
-
if (!resp.ok) {
|
|
1462
|
-
const errorStr = JSON.stringify(resp);
|
|
1463
|
-
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1464
|
-
}
|
|
1465
|
-
return attachmentMetadataSchema.parse(await resp.json());
|
|
1466
|
-
}
|
|
1467
1471
|
};
|
|
1468
1472
|
function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
1469
1473
|
id,
|
package/dist/index.mjs
CHANGED
|
@@ -1357,16 +1357,35 @@ var ReadonlyAttachment = class {
|
|
|
1357
1357
|
async data() {
|
|
1358
1358
|
return this._data.get();
|
|
1359
1359
|
}
|
|
1360
|
+
/**
|
|
1361
|
+
* Fetch the attachment metadata, which includes a downloadUrl and a status.
|
|
1362
|
+
* This will re-fetch the status each time in case it changes over time.
|
|
1363
|
+
*/
|
|
1364
|
+
async metadata() {
|
|
1365
|
+
const state = this.state ?? _globalState;
|
|
1366
|
+
await state.login({});
|
|
1367
|
+
const resp = await state.apiConn().get("/attachment", {
|
|
1368
|
+
key: this.reference.key,
|
|
1369
|
+
filename: this.reference.filename,
|
|
1370
|
+
content_type: this.reference.content_type,
|
|
1371
|
+
org_id: state.orgId || ""
|
|
1372
|
+
});
|
|
1373
|
+
if (!resp.ok) {
|
|
1374
|
+
const errorStr = JSON.stringify(resp);
|
|
1375
|
+
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1376
|
+
}
|
|
1377
|
+
return attachmentMetadataSchema.parse(await resp.json());
|
|
1378
|
+
}
|
|
1360
1379
|
/**
|
|
1361
1380
|
* Fetch the attachment upload status. This will re-fetch the status each time
|
|
1362
1381
|
* in case it changes over time.
|
|
1363
1382
|
*/
|
|
1364
1383
|
async status() {
|
|
1365
|
-
return (await this.
|
|
1384
|
+
return (await this.metadata()).status;
|
|
1366
1385
|
}
|
|
1367
1386
|
initDownloader() {
|
|
1368
1387
|
const download = async () => {
|
|
1369
|
-
const { downloadUrl, status } = await this.
|
|
1388
|
+
const { downloadUrl, status } = await this.metadata();
|
|
1370
1389
|
if (status.upload_status !== "done") {
|
|
1371
1390
|
throw new Error(
|
|
1372
1391
|
`Expected attachment status "done", got "${status.upload_status}"`
|
|
@@ -1381,21 +1400,6 @@ var ReadonlyAttachment = class {
|
|
|
1381
1400
|
};
|
|
1382
1401
|
return new LazyValue(download);
|
|
1383
1402
|
}
|
|
1384
|
-
async fetchMetadata() {
|
|
1385
|
-
const state = this.state ?? _globalState;
|
|
1386
|
-
await state.login({});
|
|
1387
|
-
const resp = await state.apiConn().get("/attachment", {
|
|
1388
|
-
key: this.reference.key,
|
|
1389
|
-
filename: this.reference.filename,
|
|
1390
|
-
content_type: this.reference.content_type,
|
|
1391
|
-
org_id: state.orgId || ""
|
|
1392
|
-
});
|
|
1393
|
-
if (!resp.ok) {
|
|
1394
|
-
const errorStr = JSON.stringify(resp);
|
|
1395
|
-
throw new Error(`Invalid response from API server: ${errorStr}`);
|
|
1396
|
-
}
|
|
1397
|
-
return attachmentMetadataSchema.parse(await resp.json());
|
|
1398
|
-
}
|
|
1399
1403
|
};
|
|
1400
1404
|
function logFeedbackImpl(state, parentObjectType, parentObjectId, {
|
|
1401
1405
|
id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "braintrust",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.181",
|
|
4
4
|
"description": "SDK for integrating Braintrust",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@ai-sdk/provider": "^1.0.1",
|
|
78
|
-
"@braintrust/core": "0.0.
|
|
78
|
+
"@braintrust/core": "0.0.75",
|
|
79
79
|
"@next/env": "^14.2.3",
|
|
80
80
|
"@vercel/functions": "^1.0.2",
|
|
81
81
|
"ai": "^3.2.16",
|