langsmith 0.5.11 → 0.5.13
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/experimental/vercel/middleware.cjs +27 -11
- package/dist/experimental/vercel/middleware.d.ts +11 -1
- package/dist/experimental/vercel/middleware.js +27 -11
- package/dist/experimental/vercel/utils.cjs +8 -0
- package/dist/experimental/vercel/utils.js +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -192,23 +192,33 @@ function LangSmithMiddleware(config) {
|
|
|
192
192
|
try {
|
|
193
193
|
const output = chunks.reduce((aggregated, chunk) => {
|
|
194
194
|
if (chunk.type === "text-delta") {
|
|
195
|
+
if (aggregated.content.at(-1)?.type !== "text") {
|
|
196
|
+
aggregated.content.push({ type: "text", text: "" });
|
|
197
|
+
}
|
|
198
|
+
const contentBlock = aggregated.content.at(-1);
|
|
195
199
|
if (chunk.delta != null) {
|
|
196
|
-
|
|
197
|
-
...aggregated,
|
|
198
|
-
content: aggregated.content + chunk.delta,
|
|
199
|
-
};
|
|
200
|
+
contentBlock.text += chunk.delta;
|
|
200
201
|
}
|
|
201
202
|
else if ("textDelta" in chunk &&
|
|
202
203
|
chunk.textDelta != null) {
|
|
203
204
|
// AI SDK 4 shim
|
|
204
|
-
|
|
205
|
-
...aggregated,
|
|
206
|
-
content: aggregated.content + chunk.textDelta,
|
|
207
|
-
};
|
|
205
|
+
contentBlock.text += chunk.textDelta;
|
|
208
206
|
}
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
return aggregated;
|
|
208
|
+
}
|
|
209
|
+
else if (chunk.type === "reasoning-delta") {
|
|
210
|
+
if (aggregated.content.at(-1)?.type !== "reasoning") {
|
|
211
|
+
aggregated.content.push({
|
|
212
|
+
type: "reasoning",
|
|
213
|
+
reasoning: "",
|
|
214
|
+
extras: chunk.providerMetadata,
|
|
215
|
+
});
|
|
211
216
|
}
|
|
217
|
+
const reasoningBlock = aggregated.content.at(-1);
|
|
218
|
+
if (chunk.delta != null) {
|
|
219
|
+
reasoningBlock.reasoning += chunk.delta;
|
|
220
|
+
}
|
|
221
|
+
return aggregated;
|
|
212
222
|
}
|
|
213
223
|
else if (chunk.type === "tool-call") {
|
|
214
224
|
const matchingToolCall = aggregated.tool_calls.find((call) => call.id === chunk.toolCallId);
|
|
@@ -250,7 +260,7 @@ function LangSmithMiddleware(config) {
|
|
|
250
260
|
return aggregated;
|
|
251
261
|
}
|
|
252
262
|
}, {
|
|
253
|
-
content:
|
|
263
|
+
content: [],
|
|
254
264
|
role: "assistant",
|
|
255
265
|
tool_calls: [],
|
|
256
266
|
});
|
|
@@ -260,6 +270,12 @@ function LangSmithMiddleware(config) {
|
|
|
260
270
|
request: rest.request,
|
|
261
271
|
response: rest.response,
|
|
262
272
|
};
|
|
273
|
+
if ("content" in outputForTracing &&
|
|
274
|
+
Array.isArray(outputForTracing.content) &&
|
|
275
|
+
outputForTracing.content.length === 1 &&
|
|
276
|
+
outputForTracing.content[0].type === "text") {
|
|
277
|
+
outputForTracing.content = outputForTracing.content[0].text;
|
|
278
|
+
}
|
|
263
279
|
let formattedOutputs;
|
|
264
280
|
if (lsConfig?.processOutputs) {
|
|
265
281
|
formattedOutputs = await lsConfig.processOutputs(outputForTracing);
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { LanguageModelV2Middleware, SharedV2ProviderMetadata, LanguageModelV2FinishReason } from "@ai-sdk/provider";
|
|
2
2
|
import type { RunTreeConfig } from "../../run_trees.js";
|
|
3
|
+
type StandardTextBlock = {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
type StandardReasoningBlock = {
|
|
8
|
+
type: "reasoning";
|
|
9
|
+
reasoning: string;
|
|
10
|
+
extras?: Record<string, unknown>;
|
|
11
|
+
};
|
|
3
12
|
export type AggregatedDoStreamOutput = {
|
|
4
|
-
content:
|
|
13
|
+
content: (StandardReasoningBlock | StandardTextBlock)[];
|
|
5
14
|
role: "assistant";
|
|
6
15
|
tool_calls: {
|
|
7
16
|
id: string;
|
|
@@ -26,3 +35,4 @@ export declare function LangSmithMiddleware(config?: {
|
|
|
26
35
|
traceRawHttp?: boolean;
|
|
27
36
|
};
|
|
28
37
|
}): LanguageModelV2Middleware;
|
|
38
|
+
export {};
|
|
@@ -189,23 +189,33 @@ export function LangSmithMiddleware(config) {
|
|
|
189
189
|
try {
|
|
190
190
|
const output = chunks.reduce((aggregated, chunk) => {
|
|
191
191
|
if (chunk.type === "text-delta") {
|
|
192
|
+
if (aggregated.content.at(-1)?.type !== "text") {
|
|
193
|
+
aggregated.content.push({ type: "text", text: "" });
|
|
194
|
+
}
|
|
195
|
+
const contentBlock = aggregated.content.at(-1);
|
|
192
196
|
if (chunk.delta != null) {
|
|
193
|
-
|
|
194
|
-
...aggregated,
|
|
195
|
-
content: aggregated.content + chunk.delta,
|
|
196
|
-
};
|
|
197
|
+
contentBlock.text += chunk.delta;
|
|
197
198
|
}
|
|
198
199
|
else if ("textDelta" in chunk &&
|
|
199
200
|
chunk.textDelta != null) {
|
|
200
201
|
// AI SDK 4 shim
|
|
201
|
-
|
|
202
|
-
...aggregated,
|
|
203
|
-
content: aggregated.content + chunk.textDelta,
|
|
204
|
-
};
|
|
202
|
+
contentBlock.text += chunk.textDelta;
|
|
205
203
|
}
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
return aggregated;
|
|
205
|
+
}
|
|
206
|
+
else if (chunk.type === "reasoning-delta") {
|
|
207
|
+
if (aggregated.content.at(-1)?.type !== "reasoning") {
|
|
208
|
+
aggregated.content.push({
|
|
209
|
+
type: "reasoning",
|
|
210
|
+
reasoning: "",
|
|
211
|
+
extras: chunk.providerMetadata,
|
|
212
|
+
});
|
|
208
213
|
}
|
|
214
|
+
const reasoningBlock = aggregated.content.at(-1);
|
|
215
|
+
if (chunk.delta != null) {
|
|
216
|
+
reasoningBlock.reasoning += chunk.delta;
|
|
217
|
+
}
|
|
218
|
+
return aggregated;
|
|
209
219
|
}
|
|
210
220
|
else if (chunk.type === "tool-call") {
|
|
211
221
|
const matchingToolCall = aggregated.tool_calls.find((call) => call.id === chunk.toolCallId);
|
|
@@ -247,7 +257,7 @@ export function LangSmithMiddleware(config) {
|
|
|
247
257
|
return aggregated;
|
|
248
258
|
}
|
|
249
259
|
}, {
|
|
250
|
-
content:
|
|
260
|
+
content: [],
|
|
251
261
|
role: "assistant",
|
|
252
262
|
tool_calls: [],
|
|
253
263
|
});
|
|
@@ -257,6 +267,12 @@ export function LangSmithMiddleware(config) {
|
|
|
257
267
|
request: rest.request,
|
|
258
268
|
response: rest.response,
|
|
259
269
|
};
|
|
270
|
+
if ("content" in outputForTracing &&
|
|
271
|
+
Array.isArray(outputForTracing.content) &&
|
|
272
|
+
outputForTracing.content.length === 1 &&
|
|
273
|
+
outputForTracing.content[0].type === "text") {
|
|
274
|
+
outputForTracing.content = outputForTracing.content[0].text;
|
|
275
|
+
}
|
|
260
276
|
let formattedOutputs;
|
|
261
277
|
if (lsConfig?.processOutputs) {
|
|
262
278
|
formattedOutputs = await lsConfig.processOutputs(outputForTracing);
|
|
@@ -146,6 +146,14 @@ const convertMessageToTracedFormat = (message, responseMetadata) => {
|
|
|
146
146
|
image_url: (0, exports.normalizeFileDataAsDataURL)(image, mediaType),
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
+
else if (part.type === "reasoning" &&
|
|
150
|
+
"text" in part &&
|
|
151
|
+
typeof part.text === "string") {
|
|
152
|
+
return {
|
|
153
|
+
type: "reasoning",
|
|
154
|
+
reasoning: part.text,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
149
157
|
return part;
|
|
150
158
|
});
|
|
151
159
|
formattedMessage.content = newContent;
|
|
@@ -142,6 +142,14 @@ export const convertMessageToTracedFormat = (message, responseMetadata) => {
|
|
|
142
142
|
image_url: normalizeFileDataAsDataURL(image, mediaType),
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
|
+
else if (part.type === "reasoning" &&
|
|
146
|
+
"text" in part &&
|
|
147
|
+
typeof part.text === "string") {
|
|
148
|
+
return {
|
|
149
|
+
type: "reasoning",
|
|
150
|
+
reasoning: part.text,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
145
153
|
return part;
|
|
146
154
|
});
|
|
147
155
|
formattedMessage.content = newContent;
|
package/dist/index.cjs
CHANGED
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
|
|
|
18
18
|
Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
|
|
19
19
|
Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
|
|
20
20
|
// Update using yarn bump-version
|
|
21
|
-
exports.__version__ = "0.5.
|
|
21
|
+
exports.__version__ = "0.5.13";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
7
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
8
|
-
export declare const __version__ = "0.5.
|
|
8
|
+
export declare const __version__ = "0.5.13";
|
package/dist/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
|
|
|
5
5
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
6
6
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
7
7
|
// Update using yarn bump-version
|
|
8
|
-
export const __version__ = "0.5.
|
|
8
|
+
export const __version__ = "0.5.13";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "yarn@1.22.19",
|
|
6
6
|
"files": [
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"ai": "^6.0.1",
|
|
181
181
|
"babel-jest": "^30.2.0",
|
|
182
182
|
"cross-env": "^10.1.0",
|
|
183
|
-
"dotenv": "^
|
|
183
|
+
"dotenv": "^17.3.1",
|
|
184
184
|
"eslint": "^8.41.0",
|
|
185
185
|
"eslint-config-prettier": "^10.1.8",
|
|
186
186
|
"eslint-plugin-import": "^2.27.5",
|