langsmith 0.10.6 → 0.10.7
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/address.cjs +15 -1
- package/dist/address.js +14 -1
- package/dist/client.cjs +1 -1
- package/dist/client.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +0 -2
- package/dist/traceable.cjs +22 -3
- package/dist/traceable.js +22 -3
- package/dist/utils/agent_addressing.cjs +12 -4
- package/dist/utils/agent_addressing.js +13 -5
- package/package.json +1 -1
package/dist/address.cjs
CHANGED
|
@@ -4,6 +4,7 @@ exports.EnvAddressError = void 0;
|
|
|
4
4
|
exports.normalizeAddress = normalizeAddress;
|
|
5
5
|
exports.wireKeys = wireKeys;
|
|
6
6
|
exports.envNames = envNames;
|
|
7
|
+
exports.toPayload = toPayload;
|
|
7
8
|
exports.toWire = toWire;
|
|
8
9
|
exports.fromWire = fromWire;
|
|
9
10
|
exports.addressFromEnv = addressFromEnv;
|
|
@@ -69,7 +70,20 @@ function wireKeys() {
|
|
|
69
70
|
function envNames() {
|
|
70
71
|
return wireKeys().map((key) => `LANGSMITH_${key.toUpperCase()}`);
|
|
71
72
|
}
|
|
72
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* @internal The `address` object of a run / feedback payload. `kind` and
|
|
75
|
+
* `environment` are uppercase and case-sensitive on the wire.
|
|
76
|
+
*/
|
|
77
|
+
function toPayload(address) {
|
|
78
|
+
return {
|
|
79
|
+
address: {
|
|
80
|
+
kind: "AGENT",
|
|
81
|
+
id: address.agentId,
|
|
82
|
+
environment: address.agentEnvironment.toUpperCase(),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/** @internal Header / replica fields. */
|
|
73
87
|
function toWire(address) {
|
|
74
88
|
return {
|
|
75
89
|
[FIELDS.agentId]: address.agentId,
|
package/dist/address.js
CHANGED
|
@@ -57,7 +57,20 @@ export function wireKeys() {
|
|
|
57
57
|
export function envNames() {
|
|
58
58
|
return wireKeys().map((key) => `LANGSMITH_${key.toUpperCase()}`);
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* @internal The `address` object of a run / feedback payload. `kind` and
|
|
62
|
+
* `environment` are uppercase and case-sensitive on the wire.
|
|
63
|
+
*/
|
|
64
|
+
export function toPayload(address) {
|
|
65
|
+
return {
|
|
66
|
+
address: {
|
|
67
|
+
kind: "AGENT",
|
|
68
|
+
id: address.agentId,
|
|
69
|
+
environment: address.agentEnvironment.toUpperCase(),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** @internal Header / replica fields. */
|
|
61
74
|
export function toWire(address) {
|
|
62
75
|
return {
|
|
63
76
|
[FIELDS.agentId]: address.agentId,
|
package/dist/client.cjs
CHANGED
|
@@ -3987,7 +3987,7 @@ class Client {
|
|
|
3987
3987
|
if (samplingId != null && !this._shouldSample(samplingId)) {
|
|
3988
3988
|
return feedback;
|
|
3989
3989
|
}
|
|
3990
|
-
const body = JSON.stringify(address ? { ...feedback, ...(0, address_js_1.
|
|
3990
|
+
const body = JSON.stringify(address ? { ...feedback, ...(0, address_js_1.toPayload)(address) } : feedback);
|
|
3991
3991
|
const url = `${this.apiUrl}/feedback`;
|
|
3992
3992
|
await this.caller.call(async () => {
|
|
3993
3993
|
const res = await this._fetch(url, {
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { Langsmith as OpenAPILangsmith } from "./_openapi_client/index.js";
|
|
|
9
9
|
import { assertUuid } from "./utils/_uuid.js";
|
|
10
10
|
import { isSampledById } from "./utils/sampling.js";
|
|
11
11
|
import { warnOnce } from "./utils/warn.js";
|
|
12
|
-
import { EnvAddressError,
|
|
12
|
+
import { EnvAddressError, toPayload } from "./address.js";
|
|
13
13
|
import { applyToPayload, checkAddress, logUntraced, rejectConflicting, resolveFromEnv, warnOnEnv, } from "./utils/agent_addressing.js";
|
|
14
14
|
import { getQueryBackend, QueryBackend } from "./utils/v2_migration.js";
|
|
15
15
|
import { parseHubIdentifier } from "./utils/prompts.js";
|
|
@@ -3948,7 +3948,7 @@ export class Client {
|
|
|
3948
3948
|
if (samplingId != null && !this._shouldSample(samplingId)) {
|
|
3949
3949
|
return feedback;
|
|
3950
3950
|
}
|
|
3951
|
-
const body = JSON.stringify(address ? { ...feedback, ...
|
|
3951
|
+
const body = JSON.stringify(address ? { ...feedback, ...toPayload(address) } : feedback);
|
|
3952
3952
|
const url = `${this.apiUrl}/feedback`;
|
|
3953
3953
|
await this.caller.call(async () => {
|
|
3954
3954
|
const res = await this._fetch(url, {
|
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,6 @@ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, g
|
|
|
37
37
|
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_js_1.RateLimitError; } });
|
|
38
38
|
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_js_1.InternalServerError; } });
|
|
39
39
|
// Update using pnpm bump-version
|
|
40
|
-
exports.__version__ = "0.10.
|
|
40
|
+
exports.__version__ = "0.10.7";
|
|
41
41
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
42
42
|
exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export { computeRunIdForSecondaryReplica, uuid7, uuid7FromTime, } from "./uuid.j
|
|
|
8
8
|
export { isTracingEnabled } from "./utils/guard.js";
|
|
9
9
|
export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
10
10
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
11
|
-
export declare const __version__ = "0.10.
|
|
11
|
+
export declare const __version__ = "0.10.7";
|
|
12
12
|
export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,6 @@ export { isTracingEnabled } from "./utils/guard.js";
|
|
|
8
8
|
export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
|
|
9
9
|
export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
|
|
10
10
|
// Update using pnpm bump-version
|
|
11
|
-
export const __version__ = "0.10.
|
|
11
|
+
export const __version__ = "0.10.7";
|
|
12
12
|
// Metadata key to hide a traced run from LangSmith's Messages View.
|
|
13
13
|
export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
|
package/dist/schemas.d.ts
CHANGED
|
@@ -150,7 +150,6 @@ export interface RunCreate extends BaseRun {
|
|
|
150
150
|
revision_id?: string;
|
|
151
151
|
child_runs?: this[];
|
|
152
152
|
session_name?: string;
|
|
153
|
-
/** (beta) Sent as `agent_id` / `agent_environment`. */
|
|
154
153
|
address?: Address;
|
|
155
154
|
}
|
|
156
155
|
export interface RunUpdate {
|
|
@@ -170,7 +169,6 @@ export interface RunUpdate {
|
|
|
170
169
|
events?: KVMap[];
|
|
171
170
|
session_id?: string;
|
|
172
171
|
session_name?: string;
|
|
173
|
-
/** (beta) Sent as `agent_id` / `agent_environment`. */
|
|
174
172
|
address?: Address;
|
|
175
173
|
/** Unique ID assigned to every run within this nested trace. **/
|
|
176
174
|
trace_id?: string;
|
package/dist/traceable.cjs
CHANGED
|
@@ -651,9 +651,28 @@ function traceable(wrappedFunc, config) {
|
|
|
651
651
|
async start(controller) {
|
|
652
652
|
// eslint-disable-next-line no-constant-condition
|
|
653
653
|
while (true) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
654
|
+
let result;
|
|
655
|
+
try {
|
|
656
|
+
result = await (snapshot
|
|
657
|
+
? snapshot(() => otel_context.with(capturedOtelContext, () => reader.read()))
|
|
658
|
+
: otel_context.with(capturedOtelContext, () => reader.read()));
|
|
659
|
+
}
|
|
660
|
+
catch (e) {
|
|
661
|
+
// The source stream errored: end the run with the error and the
|
|
662
|
+
// chunks received so far instead of leaving it pending.
|
|
663
|
+
finished = true;
|
|
664
|
+
await currentRunTree?.end(undefined, String(e));
|
|
665
|
+
await handleRunOutputs({
|
|
666
|
+
runTree: currentRunTree,
|
|
667
|
+
rawOutputs: await handleChunks(chunks),
|
|
668
|
+
processOutputsFn,
|
|
669
|
+
on_end,
|
|
670
|
+
postRunPromise,
|
|
671
|
+
deferredInputs,
|
|
672
|
+
skipChildPromiseDelay: true,
|
|
673
|
+
});
|
|
674
|
+
throw e;
|
|
675
|
+
}
|
|
657
676
|
if (result.done) {
|
|
658
677
|
finished = true;
|
|
659
678
|
await handleRunOutputs({
|
package/dist/traceable.js
CHANGED
|
@@ -647,9 +647,28 @@ export function traceable(wrappedFunc, config) {
|
|
|
647
647
|
async start(controller) {
|
|
648
648
|
// eslint-disable-next-line no-constant-condition
|
|
649
649
|
while (true) {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
650
|
+
let result;
|
|
651
|
+
try {
|
|
652
|
+
result = await (snapshot
|
|
653
|
+
? snapshot(() => otel_context.with(capturedOtelContext, () => reader.read()))
|
|
654
|
+
: otel_context.with(capturedOtelContext, () => reader.read()));
|
|
655
|
+
}
|
|
656
|
+
catch (e) {
|
|
657
|
+
// The source stream errored: end the run with the error and the
|
|
658
|
+
// chunks received so far instead of leaving it pending.
|
|
659
|
+
finished = true;
|
|
660
|
+
await currentRunTree?.end(undefined, String(e));
|
|
661
|
+
await handleRunOutputs({
|
|
662
|
+
runTree: currentRunTree,
|
|
663
|
+
rawOutputs: await handleChunks(chunks),
|
|
664
|
+
processOutputsFn,
|
|
665
|
+
on_end,
|
|
666
|
+
postRunPromise,
|
|
667
|
+
deferredInputs,
|
|
668
|
+
skipChildPromiseDelay: true,
|
|
669
|
+
});
|
|
670
|
+
throw e;
|
|
671
|
+
}
|
|
653
672
|
if (result.done) {
|
|
654
673
|
finished = true;
|
|
655
674
|
await handleRunOutputs({
|
|
@@ -10,6 +10,11 @@ exports.applyToPayload = applyToPayload;
|
|
|
10
10
|
const address_js_1 = require("../address.cjs");
|
|
11
11
|
const env_js_1 = require("./env.cjs");
|
|
12
12
|
const warn_js_1 = require("./warn.cjs");
|
|
13
|
+
function isRendered(value) {
|
|
14
|
+
return (value != null &&
|
|
15
|
+
typeof value === "object" &&
|
|
16
|
+
"kind" in value);
|
|
17
|
+
}
|
|
13
18
|
/** Validate an address at an entry point; the SDK carries the frozen copy. */
|
|
14
19
|
function checkAddress(address) {
|
|
15
20
|
return address == null ? undefined : (0, address_js_1.normalizeAddress)(address);
|
|
@@ -72,10 +77,13 @@ function warnOnEnv() {
|
|
|
72
77
|
*/
|
|
73
78
|
function applyToPayload(run, { update = false } = {}) {
|
|
74
79
|
const payload = run;
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
// Already rendered into its wire object by an earlier call.
|
|
81
|
+
const rendered = isRendered(payload.address);
|
|
82
|
+
let address = rendered ? undefined : checkAddress(payload.address);
|
|
83
|
+
if (!rendered) {
|
|
84
|
+
delete payload.address;
|
|
85
|
+
}
|
|
77
86
|
const namedProject = payload.session_id != null || payload.session_name != null;
|
|
78
|
-
const rendered = (0, address_js_1.wireKeys)().some((key) => payload[key] != null);
|
|
79
87
|
if (!address && !update && !namedProject && !rendered) {
|
|
80
88
|
address = (0, address_js_1.addressFromEnv)();
|
|
81
89
|
}
|
|
@@ -84,7 +92,7 @@ function applyToPayload(run, { update = false } = {}) {
|
|
|
84
92
|
}
|
|
85
93
|
(0, warn_js_1.warnOnce)("Sending runs to an `address` is in beta and enabled per workspace; a " +
|
|
86
94
|
"workspace without it rejects the runs.");
|
|
87
|
-
Object.assign(payload, (0, address_js_1.
|
|
95
|
+
Object.assign(payload, (0, address_js_1.toPayload)(address));
|
|
88
96
|
if (!namedProject) {
|
|
89
97
|
delete payload.session_name;
|
|
90
98
|
delete payload.session_id;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { EnvAddressError, addressFromEnv, envNames, normalizeAddress,
|
|
1
|
+
import { EnvAddressError, addressFromEnv, envNames, normalizeAddress, toPayload, } from "../address.js";
|
|
2
2
|
import { getEnvironmentVariable, getLangSmithEnvironmentVariable, } from "./env.js";
|
|
3
3
|
import { warnOnce } from "./warn.js";
|
|
4
|
+
function isRendered(value) {
|
|
5
|
+
return (value != null &&
|
|
6
|
+
typeof value === "object" &&
|
|
7
|
+
"kind" in value);
|
|
8
|
+
}
|
|
4
9
|
/** Validate an address at an entry point; the SDK carries the frozen copy. */
|
|
5
10
|
export function checkAddress(address) {
|
|
6
11
|
return address == null ? undefined : normalizeAddress(address);
|
|
@@ -63,10 +68,13 @@ export function warnOnEnv() {
|
|
|
63
68
|
*/
|
|
64
69
|
export function applyToPayload(run, { update = false } = {}) {
|
|
65
70
|
const payload = run;
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
// Already rendered into its wire object by an earlier call.
|
|
72
|
+
const rendered = isRendered(payload.address);
|
|
73
|
+
let address = rendered ? undefined : checkAddress(payload.address);
|
|
74
|
+
if (!rendered) {
|
|
75
|
+
delete payload.address;
|
|
76
|
+
}
|
|
68
77
|
const namedProject = payload.session_id != null || payload.session_name != null;
|
|
69
|
-
const rendered = wireKeys().some((key) => payload[key] != null);
|
|
70
78
|
if (!address && !update && !namedProject && !rendered) {
|
|
71
79
|
address = addressFromEnv();
|
|
72
80
|
}
|
|
@@ -75,7 +83,7 @@ export function applyToPayload(run, { update = false } = {}) {
|
|
|
75
83
|
}
|
|
76
84
|
warnOnce("Sending runs to an `address` is in beta and enabled per workspace; a " +
|
|
77
85
|
"workspace without it rejects the runs.");
|
|
78
|
-
Object.assign(payload,
|
|
86
|
+
Object.assign(payload, toPayload(address));
|
|
79
87
|
if (!namedProject) {
|
|
80
88
|
delete payload.session_name;
|
|
81
89
|
delete payload.session_id;
|