langsmith 0.3.46 → 0.3.48

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/client.cjs CHANGED
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Client = exports.DEFAULT_BATCH_SIZE_LIMIT_BYTES = exports.AutoBatchQueue = void 0;
37
- exports.mergeRuntimeEnvIntoRunCreate = mergeRuntimeEnvIntoRunCreate;
37
+ exports.mergeRuntimeEnvIntoRun = mergeRuntimeEnvIntoRun;
38
38
  const uuid = __importStar(require("uuid"));
39
39
  const translator_js_1 = require("./experimental/otel/translator.cjs");
40
40
  const otel_js_1 = require("./singletons/otel.cjs");
@@ -48,7 +48,7 @@ const prompts_js_1 = require("./utils/prompts.cjs");
48
48
  const error_js_1 = require("./utils/error.cjs");
49
49
  const fetch_js_1 = require("./singletons/fetch.cjs");
50
50
  const index_js_2 = require("./utils/fast-safe-stringify/index.cjs");
51
- function mergeRuntimeEnvIntoRunCreate(run) {
51
+ function mergeRuntimeEnvIntoRun(run) {
52
52
  const runtimeEnv = (0, env_js_1.getRuntimeEnvironment)();
53
53
  const envVars = (0, env_js_1.getLangChainEnvVarsMetadata)();
54
54
  const extra = run.extra ?? {};
@@ -61,8 +61,11 @@ function mergeRuntimeEnvIntoRunCreate(run) {
61
61
  },
62
62
  metadata: {
63
63
  ...envVars,
64
- ...(envVars.revision_id || run.revision_id
65
- ? { revision_id: run.revision_id ?? envVars.revision_id }
64
+ ...(envVars.revision_id || ("revision_id" in run && run.revision_id)
65
+ ? {
66
+ revision_id: ("revision_id" in run ? run.revision_id : undefined) ??
67
+ envVars.revision_id,
68
+ }
66
69
  : {}),
67
70
  ...metadata,
68
71
  },
@@ -724,9 +727,7 @@ class Client {
724
727
  async processRunOperation(item) {
725
728
  clearTimeout(this.autoBatchTimeout);
726
729
  this.autoBatchTimeout = undefined;
727
- if (item.action === "create") {
728
- item.item = mergeRuntimeEnvIntoRunCreate(item.item);
729
- }
730
+ item.item = mergeRuntimeEnvIntoRun(item.item);
730
731
  const itemPromise = this.autoBatchQueue.push(item);
731
732
  if (this.manualFlushMode) {
732
733
  // Rely on manual flushing in serverless environments
@@ -833,7 +834,7 @@ class Client {
833
834
  }).catch(console.error);
834
835
  return;
835
836
  }
836
- const mergedRunCreateParam = mergeRuntimeEnvIntoRunCreate(runCreate);
837
+ const mergedRunCreateParam = mergeRuntimeEnvIntoRun(runCreate);
837
838
  if (options?.apiKey !== undefined) {
838
839
  headers["x-api-key"] = options.apiKey;
839
840
  }
package/dist/client.d.ts CHANGED
@@ -260,7 +260,7 @@ type Thread = {
260
260
  last_outputs: string;
261
261
  last_error: string | null;
262
262
  };
263
- export declare function mergeRuntimeEnvIntoRunCreate(run: RunCreate): RunCreate;
263
+ export declare function mergeRuntimeEnvIntoRun<T extends RunCreate | RunUpdate>(run: T): T;
264
264
  export declare class AutoBatchQueue {
265
265
  items: {
266
266
  action: "create" | "update";
package/dist/client.js CHANGED
@@ -11,7 +11,7 @@ import { parsePromptIdentifier } from "./utils/prompts.js";
11
11
  import { raiseForStatus } from "./utils/error.js";
12
12
  import { _globalFetchImplementationIsNodeFetch, _getFetchImplementation, } from "./singletons/fetch.js";
13
13
  import { serialize as serializePayloadForTracing } from "./utils/fast-safe-stringify/index.js";
14
- export function mergeRuntimeEnvIntoRunCreate(run) {
14
+ export function mergeRuntimeEnvIntoRun(run) {
15
15
  const runtimeEnv = getRuntimeEnvironment();
16
16
  const envVars = getLangChainEnvVarsMetadata();
17
17
  const extra = run.extra ?? {};
@@ -24,8 +24,11 @@ export function mergeRuntimeEnvIntoRunCreate(run) {
24
24
  },
25
25
  metadata: {
26
26
  ...envVars,
27
- ...(envVars.revision_id || run.revision_id
28
- ? { revision_id: run.revision_id ?? envVars.revision_id }
27
+ ...(envVars.revision_id || ("revision_id" in run && run.revision_id)
28
+ ? {
29
+ revision_id: ("revision_id" in run ? run.revision_id : undefined) ??
30
+ envVars.revision_id,
31
+ }
29
32
  : {}),
30
33
  ...metadata,
31
34
  },
@@ -686,9 +689,7 @@ export class Client {
686
689
  async processRunOperation(item) {
687
690
  clearTimeout(this.autoBatchTimeout);
688
691
  this.autoBatchTimeout = undefined;
689
- if (item.action === "create") {
690
- item.item = mergeRuntimeEnvIntoRunCreate(item.item);
691
- }
692
+ item.item = mergeRuntimeEnvIntoRun(item.item);
692
693
  const itemPromise = this.autoBatchQueue.push(item);
693
694
  if (this.manualFlushMode) {
694
695
  // Rely on manual flushing in serverless environments
@@ -795,7 +796,7 @@ export class Client {
795
796
  }).catch(console.error);
796
797
  return;
797
798
  }
798
- const mergedRunCreateParam = mergeRuntimeEnvIntoRunCreate(runCreate);
799
+ const mergedRunCreateParam = mergeRuntimeEnvIntoRun(runCreate);
799
800
  if (options?.apiKey !== undefined) {
800
801
  headers["x-api-key"] = options.apiKey;
801
802
  }
@@ -138,7 +138,11 @@ class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceEx
138
138
  });
139
139
  }
140
140
  }
141
- if (span.attributes["ai.toolCall.args"]) {
141
+ if (span.attributes["ai.toolCall.input"]) {
142
+ span.attributes[constants.GENAI_PROMPT] =
143
+ span.attributes["ai.toolCall.input"];
144
+ }
145
+ else if (span.attributes["ai.toolCall.args"]) {
142
146
  span.attributes[constants.GENAI_PROMPT] =
143
147
  span.attributes["ai.toolCall.args"];
144
148
  }
@@ -176,7 +180,11 @@ class LangSmithOTLPTraceExporter extends exporter_trace_otlp_proto_1.OTLPTraceEx
176
180
  span.attributes[constants.GENAI_COMPLETION] =
177
181
  span.attributes["ai.response.toolCalls"];
178
182
  }
179
- if (span.attributes["ai.toolCall.result"]) {
183
+ if (span.attributes["ai.toolCall.output"]) {
184
+ span.attributes[constants.GENAI_COMPLETION] =
185
+ span.attributes["ai.toolCall.output"];
186
+ }
187
+ else if (span.attributes["ai.toolCall.result"]) {
180
188
  span.attributes[constants.GENAI_COMPLETION] =
181
189
  span.attributes["ai.toolCall.result"];
182
190
  }
@@ -102,7 +102,11 @@ export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
102
102
  });
103
103
  }
104
104
  }
105
- if (span.attributes["ai.toolCall.args"]) {
105
+ if (span.attributes["ai.toolCall.input"]) {
106
+ span.attributes[constants.GENAI_PROMPT] =
107
+ span.attributes["ai.toolCall.input"];
108
+ }
109
+ else if (span.attributes["ai.toolCall.args"]) {
106
110
  span.attributes[constants.GENAI_PROMPT] =
107
111
  span.attributes["ai.toolCall.args"];
108
112
  }
@@ -140,7 +144,11 @@ export class LangSmithOTLPTraceExporter extends OTLPTraceExporter {
140
144
  span.attributes[constants.GENAI_COMPLETION] =
141
145
  span.attributes["ai.response.toolCalls"];
142
146
  }
143
- if (span.attributes["ai.toolCall.result"]) {
147
+ if (span.attributes["ai.toolCall.output"]) {
148
+ span.attributes[constants.GENAI_COMPLETION] =
149
+ span.attributes["ai.toolCall.output"];
150
+ }
151
+ else if (span.attributes["ai.toolCall.result"]) {
144
152
  span.attributes[constants.GENAI_COMPLETION] =
145
153
  span.attributes["ai.toolCall.result"];
146
154
  }
package/dist/index.cjs CHANGED
@@ -10,4 +10,4 @@ Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true
10
10
  var project_js_1 = require("./utils/project.cjs");
11
11
  Object.defineProperty(exports, "getDefaultProjectName", { enumerable: true, get: function () { return project_js_1.getDefaultProjectName; } });
12
12
  // Update using yarn bump-version
13
- exports.__version__ = "0.3.46";
13
+ exports.__version__ = "0.3.48";
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, }
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
- export declare const __version__ = "0.3.46";
6
+ export declare const __version__ = "0.3.48";
package/dist/index.js CHANGED
@@ -3,4 +3,4 @@ export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  export { getDefaultProjectName } from "./utils/project.js";
5
5
  // Update using yarn bump-version
6
- export const __version__ = "0.3.46";
6
+ export const __version__ = "0.3.48";
package/dist/vercel.cjs CHANGED
@@ -18,15 +18,19 @@ function convertCoreToSmith(message) {
18
18
  return {
19
19
  type: "text",
20
20
  text: part.text,
21
+ // @ts-expect-error Backcompat for AI SDK 4
21
22
  ...part.experimental_providerMetadata,
22
23
  };
23
24
  }
24
25
  if (part.type === "tool-call") {
26
+ // @ts-expect-error Backcompat for AI SDK 4
27
+ const legacyToolCallInput = part.args;
25
28
  return {
26
29
  type: "tool_use",
27
30
  name: part.toolName,
28
31
  id: part.toolCallId,
29
- input: part.args,
32
+ input: legacyToolCallInput ?? part.input,
33
+ // @ts-expect-error Backcompat for AI SDK 4
30
34
  ...part.experimental_providerMetadata,
31
35
  };
32
36
  }
@@ -36,13 +40,15 @@ function convertCoreToSmith(message) {
36
40
  if (toolCalls.length > 0) {
37
41
  data.additional_kwargs ??= {};
38
42
  data.additional_kwargs.tool_calls = toolCalls.map((part) => {
43
+ // @ts-expect-error Backcompat for AI SDK 4
44
+ const legacyToolCallInput = part.args;
39
45
  return {
40
46
  id: part.toolCallId,
41
47
  type: "function",
42
48
  function: {
43
49
  name: part.toolName,
44
50
  id: part.toolCallId,
45
- arguments: JSON.stringify(part.args),
51
+ arguments: JSON.stringify(legacyToolCallInput ?? part.input),
46
52
  },
47
53
  };
48
54
  });
@@ -58,6 +64,7 @@ function convertCoreToSmith(message) {
58
64
  return {
59
65
  type: "text",
60
66
  text: part.text,
67
+ // @ts-expect-error Backcompat for AI SDK 4
61
68
  ...part.experimental_providerMetadata,
62
69
  };
63
70
  }
@@ -92,6 +99,7 @@ function convertCoreToSmith(message) {
92
99
  return {
93
100
  type: "image_url",
94
101
  image_url: imageUrl,
102
+ // @ts-expect-error Backcompat for AI SDK 4
95
103
  ...part.experimental_providerMetadata,
96
104
  };
97
105
  }
@@ -105,10 +113,12 @@ function convertCoreToSmith(message) {
105
113
  }
106
114
  if (message.role === "tool") {
107
115
  const res = message.content.map((toolCall) => {
116
+ // @ts-expect-error Backcompat for AI SDK 4
117
+ const legacyToolCallResult = toolCall.result;
108
118
  return {
109
119
  type: "tool",
110
120
  data: {
111
- content: JSON.stringify(toolCall.result),
121
+ content: JSON.stringify(legacyToolCallResult ?? toolCall.output),
112
122
  name: toolCall.toolName,
113
123
  tool_call_id: toolCall.toolCallId,
114
124
  },
@@ -530,12 +540,14 @@ class AISDKExporter {
530
540
  });
531
541
  }
532
542
  case "ai.toolCall": {
533
- const args = tryJson(span.attributes["ai.toolCall.args"]);
543
+ const args = tryJson(span.attributes["ai.toolCall.input"] ??
544
+ span.attributes["ai.toolCall.args"]);
534
545
  let inputs = { args };
535
546
  if (typeof args === "object" && args != null) {
536
547
  inputs = args;
537
548
  }
538
- const output = tryJson(span.attributes["ai.toolCall.result"]);
549
+ const output = tryJson(span.attributes["ai.toolCall.output"] ??
550
+ span.attributes["ai.toolCall.result"]);
539
551
  let outputs = { output };
540
552
  if (typeof output === "object" && output != null) {
541
553
  outputs = output;
package/dist/vercel.js CHANGED
@@ -15,15 +15,19 @@ function convertCoreToSmith(message) {
15
15
  return {
16
16
  type: "text",
17
17
  text: part.text,
18
+ // @ts-expect-error Backcompat for AI SDK 4
18
19
  ...part.experimental_providerMetadata,
19
20
  };
20
21
  }
21
22
  if (part.type === "tool-call") {
23
+ // @ts-expect-error Backcompat for AI SDK 4
24
+ const legacyToolCallInput = part.args;
22
25
  return {
23
26
  type: "tool_use",
24
27
  name: part.toolName,
25
28
  id: part.toolCallId,
26
- input: part.args,
29
+ input: legacyToolCallInput ?? part.input,
30
+ // @ts-expect-error Backcompat for AI SDK 4
27
31
  ...part.experimental_providerMetadata,
28
32
  };
29
33
  }
@@ -33,13 +37,15 @@ function convertCoreToSmith(message) {
33
37
  if (toolCalls.length > 0) {
34
38
  data.additional_kwargs ??= {};
35
39
  data.additional_kwargs.tool_calls = toolCalls.map((part) => {
40
+ // @ts-expect-error Backcompat for AI SDK 4
41
+ const legacyToolCallInput = part.args;
36
42
  return {
37
43
  id: part.toolCallId,
38
44
  type: "function",
39
45
  function: {
40
46
  name: part.toolName,
41
47
  id: part.toolCallId,
42
- arguments: JSON.stringify(part.args),
48
+ arguments: JSON.stringify(legacyToolCallInput ?? part.input),
43
49
  },
44
50
  };
45
51
  });
@@ -55,6 +61,7 @@ function convertCoreToSmith(message) {
55
61
  return {
56
62
  type: "text",
57
63
  text: part.text,
64
+ // @ts-expect-error Backcompat for AI SDK 4
58
65
  ...part.experimental_providerMetadata,
59
66
  };
60
67
  }
@@ -89,6 +96,7 @@ function convertCoreToSmith(message) {
89
96
  return {
90
97
  type: "image_url",
91
98
  image_url: imageUrl,
99
+ // @ts-expect-error Backcompat for AI SDK 4
92
100
  ...part.experimental_providerMetadata,
93
101
  };
94
102
  }
@@ -102,10 +110,12 @@ function convertCoreToSmith(message) {
102
110
  }
103
111
  if (message.role === "tool") {
104
112
  const res = message.content.map((toolCall) => {
113
+ // @ts-expect-error Backcompat for AI SDK 4
114
+ const legacyToolCallResult = toolCall.result;
105
115
  return {
106
116
  type: "tool",
107
117
  data: {
108
- content: JSON.stringify(toolCall.result),
118
+ content: JSON.stringify(legacyToolCallResult ?? toolCall.output),
109
119
  name: toolCall.toolName,
110
120
  tool_call_id: toolCall.toolCallId,
111
121
  },
@@ -527,12 +537,14 @@ export class AISDKExporter {
527
537
  });
528
538
  }
529
539
  case "ai.toolCall": {
530
- const args = tryJson(span.attributes["ai.toolCall.args"]);
540
+ const args = tryJson(span.attributes["ai.toolCall.input"] ??
541
+ span.attributes["ai.toolCall.args"]);
531
542
  let inputs = { args };
532
543
  if (typeof args === "object" && args != null) {
533
544
  inputs = args;
534
545
  }
535
- const output = tryJson(span.attributes["ai.toolCall.result"]);
546
+ const output = tryJson(span.attributes["ai.toolCall.output"] ??
547
+ span.attributes["ai.toolCall.result"]);
536
548
  let outputs = { output };
537
549
  if (typeof output === "object" && output != null) {
538
550
  outputs = output;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.46",
3
+ "version": "0.3.48",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [
@@ -140,8 +140,8 @@
140
140
  "uuid": "^10.0.0"
141
141
  },
142
142
  "devDependencies": {
143
- "@ai-sdk/anthropic": "^1.2.12",
144
- "@ai-sdk/openai": "^1.3.20",
143
+ "@ai-sdk/anthropic": "2.0.0-beta.8",
144
+ "@ai-sdk/openai": "2.0.0-beta.11",
145
145
  "@babel/preset-env": "^7.22.4",
146
146
  "@faker-js/faker": "^8.4.1",
147
147
  "@jest/globals": "^29.5.0",
@@ -159,7 +159,7 @@
159
159
  "@types/node-fetch": "^2.6.12",
160
160
  "@typescript-eslint/eslint-plugin": "^5.59.8",
161
161
  "@typescript-eslint/parser": "^5.59.8",
162
- "ai": "^4.3.17",
162
+ "ai": "5.0.0-beta.25",
163
163
  "babel-jest": "^29.5.0",
164
164
  "cross-env": "^7.0.3",
165
165
  "dotenv": "^16.1.3",
@@ -179,7 +179,7 @@
179
179
  "typedoc-plugin-expand-object-like-types": "^0.1.2",
180
180
  "typescript": "^5.4.5",
181
181
  "vitest": "^3.1.3",
182
- "zod": "^3.23.8"
182
+ "zod": "^3.25.76"
183
183
  },
184
184
  "peerDependencies": {
185
185
  "@opentelemetry/api": "*",