braintrust 0.2.2 → 0.2.3

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/index.mjs CHANGED
@@ -6131,6 +6131,7 @@ async function loadPrompt({
6131
6131
  projectId,
6132
6132
  slug,
6133
6133
  version,
6134
+ environment,
6134
6135
  id,
6135
6136
  defaults,
6136
6137
  noTrace = false,
@@ -6141,6 +6142,11 @@ async function loadPrompt({
6141
6142
  forceLogin,
6142
6143
  state: stateArg
6143
6144
  }) {
6145
+ if (version && environment) {
6146
+ throw new Error(
6147
+ "Cannot specify both 'version' and 'environment' parameters. Please use only one (remove the other)."
6148
+ );
6149
+ }
6144
6150
  if (id) {
6145
6151
  } else if (isEmpty(projectName) && isEmpty(projectId)) {
6146
6152
  throw new Error("Must specify either projectName or projectId");
@@ -6158,7 +6164,10 @@ async function loadPrompt({
6158
6164
  forceLogin
6159
6165
  });
6160
6166
  if (id) {
6161
- response = await state.apiConn().get_json(`v1/prompt/${id}`, {});
6167
+ response = await state.apiConn().get_json(`v1/prompt/${id}`, {
6168
+ ...version && { version },
6169
+ ...environment && { environment }
6170
+ });
6162
6171
  if (response) {
6163
6172
  response = { objects: [response] };
6164
6173
  }
@@ -6167,10 +6176,14 @@ async function loadPrompt({
6167
6176
  project_name: projectName,
6168
6177
  project_id: projectId,
6169
6178
  slug,
6170
- version
6179
+ version,
6180
+ ...environment && { environment }
6171
6181
  });
6172
6182
  }
6173
6183
  } catch (e) {
6184
+ if (environment || version) {
6185
+ throw new Error(`Prompt not found with specified parameters: ${e}`);
6186
+ }
6174
6187
  console.warn("Failed to load prompt, attempting to fall back to cache:", e);
6175
6188
  let prompt2;
6176
6189
  if (id) {
@@ -9958,7 +9971,7 @@ async function Eval(name, evaluator, reporterOrOpts) {
9958
9971
  const { data, baseExperiment: defaultBaseExperiment } = callEvaluatorData(
9959
9972
  evaluator.data
9960
9973
  );
9961
- const experiment = options.parent ? null : initExperiment2(evaluator.state, {
9974
+ const experiment = options.parent || options.noSendLogs ? null : initExperiment2(evaluator.state, {
9962
9975
  ...evaluator.projectId ? { projectId: evaluator.projectId } : { project: name },
9963
9976
  experiment: evaluator.experimentName,
9964
9977
  description: evaluator.description,
@@ -12185,7 +12198,13 @@ try {
12185
12198
  );
12186
12199
  OTEL_AVAILABLE = false;
12187
12200
  }
12188
- var FILTER_PREFIXES = ["gen_ai.", "braintrust.", "llm.", "ai."];
12201
+ var FILTER_PREFIXES = [
12202
+ "gen_ai.",
12203
+ "braintrust.",
12204
+ "llm.",
12205
+ "ai.",
12206
+ "traceloop."
12207
+ ];
12189
12208
  var AISpanProcessor = class _AISpanProcessor {
12190
12209
  static checkOtelAvailable() {
12191
12210
  if (!OTEL_AVAILABLE) {
@@ -12242,7 +12261,7 @@ var AISpanProcessor = class _AISpanProcessor {
12242
12261
  * Keep spans if:
12243
12262
  * 1. It's a root span (no parent)
12244
12263
  * 2. Custom filter returns true/false (if provided)
12245
- * 3. Span name starts with 'gen_ai.', 'braintrust.', 'llm.', or 'ai.'
12264
+ * 3. Span name starts with 'gen_ai.', 'braintrust.', 'llm.', 'ai.', or 'traceloop.'
12246
12265
  * 4. Any attribute name starts with those prefixes
12247
12266
  */
12248
12267
  shouldKeepFilteredSpan(span) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braintrust",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "SDK for integrating Braintrust",
5
5
  "repository": {
6
6
  "type": "git",
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@ai-sdk/provider": "^1.1.3",
95
- "@braintrust/core": "0.0.92",
95
+ "@braintrust/core": "0.0.93",
96
96
  "@next/env": "^14.2.3",
97
97
  "@vercel/functions": "^1.0.2",
98
98
  "argparse": "^2.0.1",