langsmith 0.5.2 → 0.5.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/client.cjs +3 -3
- package/dist/client.js +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/singletons/fetch.cjs +13 -13
- package/dist/singletons/fetch.d.ts +3 -3
- package/dist/singletons/fetch.js +11 -11
- package/dist/utils/jestlike/index.cjs +3 -0
- package/dist/utils/jestlike/index.js +3 -0
- package/package.json +6 -6
package/dist/client.cjs
CHANGED
|
@@ -1321,7 +1321,6 @@ class Client {
|
|
|
1321
1321
|
async _sendMultipartRequest(parts, context, options) {
|
|
1322
1322
|
// Create multipart form data boundary
|
|
1323
1323
|
const boundary = "----LangSmithFormBoundary" + Math.random().toString(36).slice(2);
|
|
1324
|
-
const isNodeFetch = (0, fetch_js_1._globalFetchImplementationIsNodeFetch)();
|
|
1325
1324
|
const buildBuffered = () => this._createNodeFetchBody(parts, boundary);
|
|
1326
1325
|
const buildStream = () => this._createMultipartStream(parts, boundary);
|
|
1327
1326
|
const sendWithRetry = async (bodyFactory) => {
|
|
@@ -1356,8 +1355,9 @@ class Client {
|
|
|
1356
1355
|
try {
|
|
1357
1356
|
let res;
|
|
1358
1357
|
let streamedAttempt = false;
|
|
1359
|
-
|
|
1360
|
-
if
|
|
1358
|
+
const shouldStream = (0, fetch_js_1._shouldStreamForGlobalFetchImplementation)();
|
|
1359
|
+
// attempt stream only if not disabled and not using node-fetch or Bun;
|
|
1360
|
+
if (shouldStream &&
|
|
1361
1361
|
!this.multipartStreamingDisabled &&
|
|
1362
1362
|
(0, env_js_1.getEnv)() !== "bun") {
|
|
1363
1363
|
streamedAttempt = true;
|
package/dist/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import { warnOnce } from "./utils/warn.js";
|
|
|
10
10
|
import { parsePromptIdentifier } from "./utils/prompts.js";
|
|
11
11
|
import { raiseForStatus, isLangSmithNotFoundError } from "./utils/error.js";
|
|
12
12
|
import { promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
13
|
-
import {
|
|
13
|
+
import { _shouldStreamForGlobalFetchImplementation, _getFetchImplementation, } from "./singletons/fetch.js";
|
|
14
14
|
import { serialize as serializePayloadForTracing } from "./utils/fast-safe-stringify/index.js";
|
|
15
15
|
export function mergeRuntimeEnvIntoRun(run, cachedEnvVars, omitTracedRuntimeInfo) {
|
|
16
16
|
if (omitTracedRuntimeInfo) {
|
|
@@ -1283,7 +1283,6 @@ export class Client {
|
|
|
1283
1283
|
async _sendMultipartRequest(parts, context, options) {
|
|
1284
1284
|
// Create multipart form data boundary
|
|
1285
1285
|
const boundary = "----LangSmithFormBoundary" + Math.random().toString(36).slice(2);
|
|
1286
|
-
const isNodeFetch = _globalFetchImplementationIsNodeFetch();
|
|
1287
1286
|
const buildBuffered = () => this._createNodeFetchBody(parts, boundary);
|
|
1288
1287
|
const buildStream = () => this._createMultipartStream(parts, boundary);
|
|
1289
1288
|
const sendWithRetry = async (bodyFactory) => {
|
|
@@ -1318,8 +1317,9 @@ export class Client {
|
|
|
1318
1317
|
try {
|
|
1319
1318
|
let res;
|
|
1320
1319
|
let streamedAttempt = false;
|
|
1321
|
-
|
|
1322
|
-
if
|
|
1320
|
+
const shouldStream = _shouldStreamForGlobalFetchImplementation();
|
|
1321
|
+
// attempt stream only if not disabled and not using node-fetch or Bun;
|
|
1322
|
+
if (shouldStream &&
|
|
1323
1323
|
!this.multipartStreamingDisabled &&
|
|
1324
1324
|
getEnv() !== "bun") {
|
|
1325
1325
|
streamedAttempt = true;
|
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.3";
|
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.3";
|
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.3";
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._getFetchImplementation = exports.
|
|
3
|
+
exports._getFetchImplementation = exports._shouldStreamForGlobalFetchImplementation = exports.clearFetchImplementation = exports.overrideFetchImplementation = void 0;
|
|
4
4
|
const env_js_1 = require("../utils/env.cjs");
|
|
5
5
|
// Wrap the default fetch call due to issues with illegal invocations
|
|
6
6
|
// in some environments:
|
|
7
7
|
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
8
8
|
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
9
9
|
const DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
10
|
+
let globalFetchSupportsWebStreaming = undefined;
|
|
10
11
|
const LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for("ls:fetch_implementation");
|
|
11
12
|
/**
|
|
12
13
|
* Overrides the fetch implementation used for LangSmith calls.
|
|
13
14
|
* You should use this if you need to use an implementation of fetch
|
|
14
15
|
* other than the default global (e.g. for dealing with proxies).
|
|
15
|
-
* @param fetch The new fetch
|
|
16
|
+
* @param fetch The new fetch function to use.
|
|
16
17
|
*/
|
|
17
|
-
const overrideFetchImplementation = (fetch) => {
|
|
18
|
+
const overrideFetchImplementation = (fetch, supportsWebStreaming) => {
|
|
18
19
|
globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;
|
|
20
|
+
globalFetchSupportsWebStreaming = supportsWebStreaming;
|
|
19
21
|
};
|
|
20
22
|
exports.overrideFetchImplementation = overrideFetchImplementation;
|
|
21
23
|
const clearFetchImplementation = () => {
|
|
22
24
|
delete globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY];
|
|
25
|
+
globalFetchSupportsWebStreaming = undefined;
|
|
23
26
|
};
|
|
24
27
|
exports.clearFetchImplementation = clearFetchImplementation;
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
"Headers" in fetchImpl &&
|
|
32
|
-
"Request" in fetchImpl &&
|
|
33
|
-
"Response" in fetchImpl);
|
|
28
|
+
const _shouldStreamForGlobalFetchImplementation = () => {
|
|
29
|
+
const overriddenFetchImpl = globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY];
|
|
30
|
+
if (overriddenFetchImpl === undefined) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return globalFetchSupportsWebStreaming ?? false;
|
|
34
34
|
};
|
|
35
|
-
exports.
|
|
35
|
+
exports._shouldStreamForGlobalFetchImplementation = _shouldStreamForGlobalFetchImplementation;
|
|
36
36
|
/**
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Overrides the fetch implementation used for LangSmith calls.
|
|
3
3
|
* You should use this if you need to use an implementation of fetch
|
|
4
4
|
* other than the default global (e.g. for dealing with proxies).
|
|
5
|
-
* @param fetch The new fetch
|
|
5
|
+
* @param fetch The new fetch function to use.
|
|
6
6
|
*/
|
|
7
|
-
export declare const overrideFetchImplementation: (fetch: (...args: any[]) => any) => void;
|
|
7
|
+
export declare const overrideFetchImplementation: (fetch: (...args: any[]) => any, supportsWebStreaming?: boolean) => void;
|
|
8
8
|
export declare const clearFetchImplementation: () => void;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const _shouldStreamForGlobalFetchImplementation: () => boolean;
|
package/dist/singletons/fetch.js
CHANGED
|
@@ -4,28 +4,28 @@ import { getLangSmithEnvironmentVariable } from "../utils/env.js";
|
|
|
4
4
|
// https://stackoverflow.com/questions/69876859/why-does-bind-fix-failed-to-execute-fetch-on-window-illegal-invocation-err
|
|
5
5
|
// @ts-expect-error Broad typing to support a range of fetch implementations
|
|
6
6
|
const DEFAULT_FETCH_IMPLEMENTATION = (...args) => fetch(...args);
|
|
7
|
+
let globalFetchSupportsWebStreaming = undefined;
|
|
7
8
|
const LANGSMITH_FETCH_IMPLEMENTATION_KEY = Symbol.for("ls:fetch_implementation");
|
|
8
9
|
/**
|
|
9
10
|
* Overrides the fetch implementation used for LangSmith calls.
|
|
10
11
|
* You should use this if you need to use an implementation of fetch
|
|
11
12
|
* other than the default global (e.g. for dealing with proxies).
|
|
12
|
-
* @param fetch The new fetch
|
|
13
|
+
* @param fetch The new fetch function to use.
|
|
13
14
|
*/
|
|
14
|
-
export const overrideFetchImplementation = (fetch) => {
|
|
15
|
+
export const overrideFetchImplementation = (fetch, supportsWebStreaming) => {
|
|
15
16
|
globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY] = fetch;
|
|
17
|
+
globalFetchSupportsWebStreaming = supportsWebStreaming;
|
|
16
18
|
};
|
|
17
19
|
export const clearFetchImplementation = () => {
|
|
18
20
|
delete globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY];
|
|
21
|
+
globalFetchSupportsWebStreaming = undefined;
|
|
19
22
|
};
|
|
20
|
-
export const
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
"Headers" in fetchImpl &&
|
|
27
|
-
"Request" in fetchImpl &&
|
|
28
|
-
"Response" in fetchImpl);
|
|
23
|
+
export const _shouldStreamForGlobalFetchImplementation = () => {
|
|
24
|
+
const overriddenFetchImpl = globalThis[LANGSMITH_FETCH_IMPLEMENTATION_KEY];
|
|
25
|
+
if (overriddenFetchImpl === undefined) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return globalFetchSupportsWebStreaming ?? false;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* @internal
|
|
@@ -517,6 +517,9 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
517
517
|
const strippedErrorMessage = e.message.replace(constants_js_1.STRIP_ANSI_REGEX, "");
|
|
518
518
|
const langsmithFriendlyError = new Error(strippedErrorMessage);
|
|
519
519
|
langsmithFriendlyError.rawJestError = rawError;
|
|
520
|
+
if (testContext.testRootRunTree) {
|
|
521
|
+
testContext.testRootRunTree.outputs = loggedOutput;
|
|
522
|
+
}
|
|
520
523
|
throw langsmithFriendlyError;
|
|
521
524
|
}
|
|
522
525
|
});
|
|
@@ -470,6 +470,9 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
470
470
|
const strippedErrorMessage = e.message.replace(STRIP_ANSI_REGEX, "");
|
|
471
471
|
const langsmithFriendlyError = new Error(strippedErrorMessage);
|
|
472
472
|
langsmithFriendlyError.rawJestError = rawError;
|
|
473
|
+
if (testContext.testRootRunTree) {
|
|
474
|
+
testContext.testRootRunTree.outputs = loggedOutput;
|
|
475
|
+
}
|
|
473
476
|
throw langsmithFriendlyError;
|
|
474
477
|
}
|
|
475
478
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langsmith",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
|
|
5
5
|
"packageManager": "yarn@1.22.19",
|
|
6
6
|
"files": [
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"@ai-sdk/provider": "^3.0.0",
|
|
159
159
|
"@anthropic-ai/claude-agent-sdk": "^0.2.34",
|
|
160
160
|
"@google/genai": "^1.29.0",
|
|
161
|
-
"@anthropic-ai/sdk": "^0.
|
|
161
|
+
"@anthropic-ai/sdk": "^0.74.0",
|
|
162
162
|
"@babel/preset-env": "^7.22.4",
|
|
163
163
|
"@faker-js/faker": "^8.4.1",
|
|
164
164
|
"@jest/globals": "^29.5.0",
|
|
@@ -178,18 +178,18 @@
|
|
|
178
178
|
"@typescript-eslint/parser": "^5.59.8",
|
|
179
179
|
"ai": "^6.0.1",
|
|
180
180
|
"babel-jest": "^30.2.0",
|
|
181
|
-
"cross-env": "^
|
|
181
|
+
"cross-env": "^10.1.0",
|
|
182
182
|
"dotenv": "^16.1.3",
|
|
183
183
|
"eslint": "^8.41.0",
|
|
184
|
-
"eslint-config-prettier": "^
|
|
184
|
+
"eslint-config-prettier": "^10.1.8",
|
|
185
185
|
"eslint-plugin-import": "^2.27.5",
|
|
186
186
|
"eslint-plugin-no-instanceof": "^1.0.1",
|
|
187
187
|
"eslint-plugin-prettier": "^4.2.1",
|
|
188
188
|
"jest": "^29.5.0",
|
|
189
189
|
"langchain": "^0.3.29",
|
|
190
190
|
"msw": "^2.11.2",
|
|
191
|
-
"node-fetch": "^
|
|
192
|
-
"openai": "^
|
|
191
|
+
"node-fetch": "^3.3.2",
|
|
192
|
+
"openai": "^6.18.0",
|
|
193
193
|
"prettier": "^2.8.8",
|
|
194
194
|
"ts-jest": "^29.1.0",
|
|
195
195
|
"ts-node": "^10.9.1",
|