langsmith 0.0.31 → 0.0.33
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/schemas.d.ts +52 -8
- package/dist/utils/env.cjs +45 -1
- package/dist/utils/env.d.ts +10 -0
- package/dist/utils/env.js +43 -0
- package/package.json +1 -1
package/dist/schemas.d.ts
CHANGED
|
@@ -26,32 +26,75 @@ export interface BaseExample {
|
|
|
26
26
|
inputs: KVMap;
|
|
27
27
|
outputs?: KVMap;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* A run can represent either a trace (root run)
|
|
31
|
+
* or a child run (~span).
|
|
32
|
+
*/
|
|
29
33
|
export interface BaseRun {
|
|
34
|
+
/** Optionally, a unique identifier for the run. */
|
|
30
35
|
id?: string;
|
|
36
|
+
/** A human-readable name for the run. */
|
|
31
37
|
name: string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
/** Defines the sequence in which the run was executed. */
|
|
39
|
+
execution_order?: number;
|
|
40
|
+
/** The epoch time at which the run started, if available. */
|
|
35
41
|
start_time?: number;
|
|
42
|
+
/** Specifies the type of run (tool, chain, llm, etc.). */
|
|
43
|
+
run_type: string;
|
|
44
|
+
/** The epoch time at which the run ended, if applicable. */
|
|
36
45
|
end_time?: number;
|
|
46
|
+
/** Any additional metadata or settings for the run. */
|
|
37
47
|
extra?: KVMap;
|
|
48
|
+
/** Error message, captured if the run faces any issues. */
|
|
38
49
|
error?: string;
|
|
39
|
-
|
|
50
|
+
/** Serialized state of the run for potential future use. */
|
|
51
|
+
serialized?: object;
|
|
52
|
+
/** Events like 'start', 'end' linked to the run. */
|
|
53
|
+
events?: KVMap[];
|
|
54
|
+
/** Inputs that were used to initiate the run. */
|
|
55
|
+
inputs: KVMap;
|
|
56
|
+
/** Outputs produced by the run, if any. */
|
|
40
57
|
outputs?: KVMap;
|
|
58
|
+
/** ID of an example that might be related to this run. */
|
|
41
59
|
reference_example_id?: string;
|
|
60
|
+
/** ID of a parent run, if this run is part of a larger operation. */
|
|
42
61
|
parent_run_id?: string;
|
|
43
|
-
|
|
62
|
+
/** Tags for further categorizing or annotating the run. */
|
|
44
63
|
tags?: string[];
|
|
45
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Describes properties of a run when loaded from the database.
|
|
67
|
+
* Extends the BaseRun interface.
|
|
68
|
+
*/
|
|
46
69
|
export interface Run extends BaseRun {
|
|
70
|
+
/** A unique identifier for the run, mandatory when loaded from DB. */
|
|
47
71
|
id: string;
|
|
48
|
-
|
|
72
|
+
/** Defines the sequence in which the run was executed. */
|
|
49
73
|
execution_order: number;
|
|
50
|
-
|
|
74
|
+
/** The ID of the project that owns this run. */
|
|
75
|
+
session_id?: string;
|
|
76
|
+
/** IDs of any child runs spawned by this run. */
|
|
51
77
|
child_run_ids?: string[];
|
|
52
|
-
|
|
78
|
+
/** Child runs, loaded explicitly via a heavier query. */
|
|
53
79
|
child_runs?: Run[];
|
|
80
|
+
/** Stats capturing feedback for this run. */
|
|
81
|
+
feedback_stats?: KVMap;
|
|
82
|
+
/** The URL path where this run is accessible within the app. */
|
|
54
83
|
app_path?: string;
|
|
84
|
+
/** The manifest ID that correlates with this run. */
|
|
85
|
+
manifest_id?: string;
|
|
86
|
+
/** The current status of the run, such as 'success'. */
|
|
87
|
+
status?: string;
|
|
88
|
+
/** Number of tokens used in the prompt. */
|
|
89
|
+
prompt_tokens?: number;
|
|
90
|
+
/** Number of tokens generated in the completion. */
|
|
91
|
+
completion_tokens?: number;
|
|
92
|
+
/** Total token count, combining prompt and completion. */
|
|
93
|
+
total_tokens?: number;
|
|
94
|
+
/** Time when the first token was processed. */
|
|
95
|
+
first_token_time?: number;
|
|
96
|
+
/** IDs of parent runs, if multiple exist. */
|
|
97
|
+
parent_run_ids?: string[];
|
|
55
98
|
}
|
|
56
99
|
export interface RunCreate extends BaseRun {
|
|
57
100
|
child_runs?: this[];
|
|
@@ -61,6 +104,7 @@ export interface RunUpdate {
|
|
|
61
104
|
end_time?: number;
|
|
62
105
|
extra?: KVMap;
|
|
63
106
|
error?: string;
|
|
107
|
+
inputs?: KVMap;
|
|
64
108
|
outputs?: KVMap;
|
|
65
109
|
parent_run_id?: string;
|
|
66
110
|
reference_example_id?: string;
|
package/dist/utils/env.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setEnvironmentVariable = exports.getEnvironmentVariable = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
|
|
3
|
+
exports.getShas = exports.setEnvironmentVariable = exports.getEnvironmentVariable = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
|
|
4
4
|
const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
5
5
|
exports.isBrowser = isBrowser;
|
|
6
6
|
const isWebWorker = () => typeof globalThis === "object" &&
|
|
@@ -49,9 +49,11 @@ let runtimeEnvironment;
|
|
|
49
49
|
async function getRuntimeEnvironment() {
|
|
50
50
|
if (runtimeEnvironment === undefined) {
|
|
51
51
|
const env = (0, exports.getEnv)();
|
|
52
|
+
const releaseEnv = getShas();
|
|
52
53
|
runtimeEnvironment = {
|
|
53
54
|
library: "langsmith",
|
|
54
55
|
runtime: env,
|
|
56
|
+
...releaseEnv,
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
return runtimeEnvironment;
|
|
@@ -78,3 +80,45 @@ function setEnvironmentVariable(name, value) {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
exports.setEnvironmentVariable = setEnvironmentVariable;
|
|
83
|
+
let cachedCommitSHAs;
|
|
84
|
+
/**
|
|
85
|
+
* Get the Git commit SHA from common environment variables
|
|
86
|
+
* used by different CI/CD platforms.
|
|
87
|
+
* @returns {string | undefined} The Git commit SHA or undefined if not found.
|
|
88
|
+
*/
|
|
89
|
+
function getShas() {
|
|
90
|
+
if (cachedCommitSHAs !== undefined) {
|
|
91
|
+
return cachedCommitSHAs;
|
|
92
|
+
}
|
|
93
|
+
const common_release_envs = [
|
|
94
|
+
"VERCEL_GIT_COMMIT_SHA",
|
|
95
|
+
"NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA",
|
|
96
|
+
"COMMIT_REF",
|
|
97
|
+
"RENDER_GIT_COMMIT",
|
|
98
|
+
"CI_COMMIT_SHA",
|
|
99
|
+
"CIRCLE_SHA1",
|
|
100
|
+
"CF_PAGES_COMMIT_SHA",
|
|
101
|
+
"REACT_APP_GIT_SHA",
|
|
102
|
+
"SOURCE_VERSION",
|
|
103
|
+
"GITHUB_SHA",
|
|
104
|
+
"TRAVIS_COMMIT",
|
|
105
|
+
"GIT_COMMIT",
|
|
106
|
+
"BUILD_VCS_NUMBER",
|
|
107
|
+
"bamboo_planRepository_revision",
|
|
108
|
+
"Build.SourceVersion",
|
|
109
|
+
"BITBUCKET_COMMIT",
|
|
110
|
+
"DRONE_COMMIT_SHA",
|
|
111
|
+
"SEMAPHORE_GIT_SHA",
|
|
112
|
+
"BUILDKITE_COMMIT",
|
|
113
|
+
];
|
|
114
|
+
const shas = {};
|
|
115
|
+
for (const env of common_release_envs) {
|
|
116
|
+
const envVar = getEnvironmentVariable(env);
|
|
117
|
+
if (envVar !== undefined) {
|
|
118
|
+
shas[env] = envVar;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
cachedCommitSHAs = shas;
|
|
122
|
+
return shas;
|
|
123
|
+
}
|
|
124
|
+
exports.getShas = getShas;
|
package/dist/utils/env.d.ts
CHANGED
|
@@ -20,3 +20,13 @@ export type RuntimeEnvironment = {
|
|
|
20
20
|
export declare function getRuntimeEnvironment(): Promise<RuntimeEnvironment>;
|
|
21
21
|
export declare function getEnvironmentVariable(name: string): string | undefined;
|
|
22
22
|
export declare function setEnvironmentVariable(name: string, value: string): void;
|
|
23
|
+
interface ICommitSHAs {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the Git commit SHA from common environment variables
|
|
28
|
+
* used by different CI/CD platforms.
|
|
29
|
+
* @returns {string | undefined} The Git commit SHA or undefined if not found.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getShas(): ICommitSHAs;
|
|
32
|
+
export {};
|
package/dist/utils/env.js
CHANGED
|
@@ -40,9 +40,11 @@ let runtimeEnvironment;
|
|
|
40
40
|
export async function getRuntimeEnvironment() {
|
|
41
41
|
if (runtimeEnvironment === undefined) {
|
|
42
42
|
const env = getEnv();
|
|
43
|
+
const releaseEnv = getShas();
|
|
43
44
|
runtimeEnvironment = {
|
|
44
45
|
library: "langsmith",
|
|
45
46
|
runtime: env,
|
|
47
|
+
...releaseEnv,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
return runtimeEnvironment;
|
|
@@ -66,3 +68,44 @@ export function setEnvironmentVariable(name, value) {
|
|
|
66
68
|
process.env[name] = value;
|
|
67
69
|
}
|
|
68
70
|
}
|
|
71
|
+
let cachedCommitSHAs;
|
|
72
|
+
/**
|
|
73
|
+
* Get the Git commit SHA from common environment variables
|
|
74
|
+
* used by different CI/CD platforms.
|
|
75
|
+
* @returns {string | undefined} The Git commit SHA or undefined if not found.
|
|
76
|
+
*/
|
|
77
|
+
export function getShas() {
|
|
78
|
+
if (cachedCommitSHAs !== undefined) {
|
|
79
|
+
return cachedCommitSHAs;
|
|
80
|
+
}
|
|
81
|
+
const common_release_envs = [
|
|
82
|
+
"VERCEL_GIT_COMMIT_SHA",
|
|
83
|
+
"NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA",
|
|
84
|
+
"COMMIT_REF",
|
|
85
|
+
"RENDER_GIT_COMMIT",
|
|
86
|
+
"CI_COMMIT_SHA",
|
|
87
|
+
"CIRCLE_SHA1",
|
|
88
|
+
"CF_PAGES_COMMIT_SHA",
|
|
89
|
+
"REACT_APP_GIT_SHA",
|
|
90
|
+
"SOURCE_VERSION",
|
|
91
|
+
"GITHUB_SHA",
|
|
92
|
+
"TRAVIS_COMMIT",
|
|
93
|
+
"GIT_COMMIT",
|
|
94
|
+
"BUILD_VCS_NUMBER",
|
|
95
|
+
"bamboo_planRepository_revision",
|
|
96
|
+
"Build.SourceVersion",
|
|
97
|
+
"BITBUCKET_COMMIT",
|
|
98
|
+
"DRONE_COMMIT_SHA",
|
|
99
|
+
"SEMAPHORE_GIT_SHA",
|
|
100
|
+
"BUILDKITE_COMMIT",
|
|
101
|
+
];
|
|
102
|
+
const shas = {};
|
|
103
|
+
for (const env of common_release_envs) {
|
|
104
|
+
const envVar = getEnvironmentVariable(env);
|
|
105
|
+
if (envVar !== undefined) {
|
|
106
|
+
shas[env] = envVar;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
cachedCommitSHAs = shas;
|
|
110
|
+
return shas;
|
|
111
|
+
}
|