langsmith 0.1.21 → 0.1.22

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.
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultRevisionId = exports.getGitInfo = void 0;
4
+ async function importChildProcess() {
5
+ const { exec } = await import("child_process");
6
+ return { exec };
7
+ }
8
+ const execGit = (command, exec) => {
9
+ return new Promise((resolve) => {
10
+ exec(`git ${command.join(" ")}`, (error, stdout) => {
11
+ if (error) {
12
+ resolve(null);
13
+ }
14
+ else {
15
+ resolve(stdout.trim());
16
+ }
17
+ });
18
+ });
19
+ };
20
+ const getGitInfo = async (remote = "origin") => {
21
+ let exec;
22
+ try {
23
+ const execImport = await importChildProcess();
24
+ exec = execImport.exec;
25
+ }
26
+ catch (e) {
27
+ // no-op
28
+ return null;
29
+ }
30
+ const isInsideWorkTree = await execGit(["rev-parse", "--is-inside-work-tree"], exec);
31
+ if (!isInsideWorkTree) {
32
+ return null;
33
+ }
34
+ const [remoteUrl, commit, commitTime, branch, tags, dirty, authorName, authorEmail,] = await Promise.all([
35
+ execGit(["remote", "get-url", remote], exec),
36
+ execGit(["rev-parse", "HEAD"], exec),
37
+ execGit(["log", "-1", "--format=%ct"], exec),
38
+ execGit(["rev-parse", "--abbrev-ref", "HEAD"], exec),
39
+ execGit(["describe", "--tags", "--exact-match", "--always", "--dirty"], exec),
40
+ execGit(["status", "--porcelain"], exec).then((output) => output !== ""),
41
+ execGit(["log", "-1", "--format=%an"], exec),
42
+ execGit(["log", "-1", "--format=%ae"], exec),
43
+ ]);
44
+ return {
45
+ remoteUrl,
46
+ commit,
47
+ commitTime,
48
+ branch,
49
+ tags,
50
+ dirty,
51
+ authorName,
52
+ authorEmail,
53
+ };
54
+ };
55
+ exports.getGitInfo = getGitInfo;
56
+ const getDefaultRevisionId = async () => {
57
+ let exec;
58
+ try {
59
+ const execImport = await importChildProcess();
60
+ exec = execImport.exec;
61
+ }
62
+ catch (e) {
63
+ // no-op
64
+ return null;
65
+ }
66
+ const commit = await execGit(["rev-parse", "HEAD"], exec);
67
+ if (!commit) {
68
+ return null;
69
+ }
70
+ return commit;
71
+ };
72
+ exports.getDefaultRevisionId = getDefaultRevisionId;
@@ -0,0 +1,14 @@
1
+ interface GitInfo {
2
+ remoteUrl?: string | null;
3
+ commit?: string | null;
4
+ branch?: string | null;
5
+ authorName?: string | null;
6
+ authorEmail?: string | null;
7
+ commitMessage?: string | null;
8
+ commitTime?: string | null;
9
+ dirty?: boolean | null;
10
+ tags?: string | null;
11
+ }
12
+ export declare const getGitInfo: (remote?: string) => Promise<GitInfo | null>;
13
+ export declare const getDefaultRevisionId: () => Promise<string | null>;
14
+ export {};
@@ -0,0 +1,67 @@
1
+ async function importChildProcess() {
2
+ const { exec } = await import("child_process");
3
+ return { exec };
4
+ }
5
+ const execGit = (command, exec) => {
6
+ return new Promise((resolve) => {
7
+ exec(`git ${command.join(" ")}`, (error, stdout) => {
8
+ if (error) {
9
+ resolve(null);
10
+ }
11
+ else {
12
+ resolve(stdout.trim());
13
+ }
14
+ });
15
+ });
16
+ };
17
+ export const getGitInfo = async (remote = "origin") => {
18
+ let exec;
19
+ try {
20
+ const execImport = await importChildProcess();
21
+ exec = execImport.exec;
22
+ }
23
+ catch (e) {
24
+ // no-op
25
+ return null;
26
+ }
27
+ const isInsideWorkTree = await execGit(["rev-parse", "--is-inside-work-tree"], exec);
28
+ if (!isInsideWorkTree) {
29
+ return null;
30
+ }
31
+ const [remoteUrl, commit, commitTime, branch, tags, dirty, authorName, authorEmail,] = await Promise.all([
32
+ execGit(["remote", "get-url", remote], exec),
33
+ execGit(["rev-parse", "HEAD"], exec),
34
+ execGit(["log", "-1", "--format=%ct"], exec),
35
+ execGit(["rev-parse", "--abbrev-ref", "HEAD"], exec),
36
+ execGit(["describe", "--tags", "--exact-match", "--always", "--dirty"], exec),
37
+ execGit(["status", "--porcelain"], exec).then((output) => output !== ""),
38
+ execGit(["log", "-1", "--format=%an"], exec),
39
+ execGit(["log", "-1", "--format=%ae"], exec),
40
+ ]);
41
+ return {
42
+ remoteUrl,
43
+ commit,
44
+ commitTime,
45
+ branch,
46
+ tags,
47
+ dirty,
48
+ authorName,
49
+ authorEmail,
50
+ };
51
+ };
52
+ export const getDefaultRevisionId = async () => {
53
+ let exec;
54
+ try {
55
+ const execImport = await importChildProcess();
56
+ exec = execImport.exec;
57
+ }
58
+ catch (e) {
59
+ // no-op
60
+ return null;
61
+ }
62
+ const commit = await execGit(["rev-parse", "HEAD"], exec);
63
+ if (!commit) {
64
+ return null;
65
+ }
66
+ return commit;
67
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.assertUuid = void 0;
27
+ const uuid = __importStar(require("uuid"));
28
+ function assertUuid(str) {
29
+ if (!uuid.validate(str)) {
30
+ throw new Error(`Invalid UUID: ${str}`);
31
+ }
32
+ }
33
+ exports.assertUuid = assertUuid;
@@ -0,0 +1 @@
1
+ export declare function assertUuid(str: string): void;
@@ -0,0 +1,6 @@
1
+ import * as uuid from "uuid";
2
+ export function assertUuid(str) {
3
+ if (!uuid.validate(str)) {
4
+ throw new Error(`Invalid UUID: ${str}`);
5
+ }
6
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.atee = void 0;
4
+ function atee(iter, length = 2) {
5
+ const buffers = Array.from({ length }, () => []);
6
+ return buffers.map(async function* makeIter(buffer) {
7
+ while (true) {
8
+ if (buffer.length === 0) {
9
+ const result = await iter.next();
10
+ for (const buffer of buffers) {
11
+ buffer.push(result);
12
+ }
13
+ }
14
+ else if (buffer[0].done) {
15
+ return;
16
+ }
17
+ else {
18
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
+ yield buffer.shift().value;
20
+ }
21
+ }
22
+ });
23
+ }
24
+ exports.atee = atee;
@@ -0,0 +1 @@
1
+ export declare function atee<T>(iter: AsyncGenerator<T>, length?: number): AsyncGenerator<T>[];
@@ -0,0 +1,20 @@
1
+ export function atee(iter, length = 2) {
2
+ const buffers = Array.from({ length }, () => []);
3
+ return buffers.map(async function* makeIter(buffer) {
4
+ while (true) {
5
+ if (buffer.length === 0) {
6
+ const result = await iter.next();
7
+ for (const buffer of buffers) {
8
+ buffer.push(result);
9
+ }
10
+ }
11
+ else if (buffer[0].done) {
12
+ return;
13
+ }
14
+ else {
15
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
16
+ yield buffer.shift().value;
17
+ }
18
+ }
19
+ });
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
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": [