langsmith
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -141,2 +141,3 @@ import { AsyncCallerParams } from "./utils/async_caller.js"; | ||
} | ||
type RecordStringAny = Record<string, any>; | ||
export type FeedbackSourceType = "model" | "api" | "app"; | ||
@@ -317,5 +318,5 @@ export type CreateExampleOptions = { | ||
description?: string | null; | ||
metadata?: Record<string, any> | null; | ||
metadata?: RecordStringAny | null; | ||
upsert?: boolean; | ||
projectExtra?: Record<string, any> | null; | ||
projectExtra?: RecordStringAny | null; | ||
referenceDatasetId?: string | null; | ||
@@ -326,4 +327,4 @@ }): Promise<TracerSession>; | ||
description?: string | null; | ||
metadata?: Record<string, any> | null; | ||
projectExtra?: Record<string, any> | null; | ||
metadata?: RecordStringAny | null; | ||
projectExtra?: RecordStringAny | null; | ||
endTime?: string | null; | ||
@@ -330,0 +331,0 @@ }): Promise<TracerSession>; |
export { Client } from "./client.js"; | ||
export type { Dataset, Example, TracerSession, Run, Feedback, } from "./schemas.js"; | ||
export { RunTree, type RunTreeConfig } from "./run_trees.js"; | ||
export declare const __version__ = "0.1.19"; | ||
export declare const __version__ = "0.1.20"; |
export { Client } from "./client.js"; | ||
export { RunTree } from "./run_trees.js"; | ||
// Update using yarn bump-version | ||
export const __version__ = "0.1.19"; | ||
export const __version__ = "0.1.20"; |
import { AsyncLocalStorage } from "async_hooks"; | ||
import { RunTree, isRunTree, isRunnableConfigLike, } from "./run_trees.js"; | ||
import { getEnvironmentVariable } from "./utils/env.js"; | ||
const asyncLocalStorage = new AsyncLocalStorage(); | ||
@@ -8,2 +9,10 @@ const isAsyncIterable = (x) => x != null && | ||
typeof x[Symbol.asyncIterator] === "function"; | ||
const getTracingRunTree = (runTree) => { | ||
const tracingEnabled = getEnvironmentVariable("LANGSMITH_TRACING_V2") === "true" || | ||
getEnvironmentVariable("LANGCHAIN_TRACING_V2") === "true"; | ||
if (!tracingEnabled) { | ||
return undefined; | ||
} | ||
return runTree; | ||
}; | ||
/** | ||
@@ -50,2 +59,3 @@ * Higher-order function that takes function as input and returns a | ||
} | ||
currentRunTree = getTracingRunTree(currentRunTree); | ||
let inputs; | ||
@@ -65,6 +75,8 @@ const firstInput = rawInputs[0]; | ||
} | ||
currentRunTree.inputs = inputs; | ||
const initialOutputs = currentRunTree.outputs; | ||
const initialError = currentRunTree.error; | ||
await currentRunTree.postRun(); | ||
if (currentRunTree) { | ||
currentRunTree.inputs = inputs; | ||
} | ||
const initialOutputs = currentRunTree?.outputs; | ||
const initialError = currentRunTree?.error; | ||
await currentRunTree?.postRun(); | ||
return new Promise((resolve, reject) => { | ||
@@ -98,8 +110,8 @@ void asyncLocalStorage.run(currentRunTree, async () => { | ||
!Array.isArray(finalOutputs)) { | ||
await currentRunTree.end(finalOutputs); | ||
await currentRunTree?.end(finalOutputs); | ||
} | ||
else { | ||
await currentRunTree.end({ outputs: finalOutputs }); | ||
await currentRunTree?.end({ outputs: finalOutputs }); | ||
} | ||
await currentRunTree.patchRun(); | ||
await currentRunTree?.patchRun(); | ||
} | ||
@@ -112,9 +124,11 @@ return resolve(wrapOutputForTracing()); | ||
: { outputs: rawOutput }; | ||
if (initialOutputs === currentRunTree.outputs) { | ||
await currentRunTree.end(outputs); | ||
if (initialOutputs === currentRunTree?.outputs) { | ||
await currentRunTree?.end(outputs); | ||
} | ||
else { | ||
currentRunTree.end_time = Date.now(); | ||
if (currentRunTree !== undefined) { | ||
currentRunTree.end_time = Date.now(); | ||
} | ||
} | ||
await currentRunTree.patchRun(); | ||
await currentRunTree?.patchRun(); | ||
return resolve(rawOutput); | ||
@@ -124,9 +138,11 @@ } | ||
catch (error) { | ||
if (initialError === currentRunTree.error) { | ||
await currentRunTree.end(initialOutputs, String(error)); | ||
if (initialError === currentRunTree?.error) { | ||
await currentRunTree?.end(initialOutputs, String(error)); | ||
} | ||
else { | ||
currentRunTree.end_time = Date.now(); | ||
if (currentRunTree !== undefined) { | ||
currentRunTree.end_time = Date.now(); | ||
} | ||
} | ||
await currentRunTree.patchRun(); | ||
await currentRunTree?.patchRun(); | ||
reject(error); | ||
@@ -133,0 +149,0 @@ } |
@@ -1,2 +0,4 @@ | ||
export function isLangChainMessage(message) { | ||
export function isLangChainMessage( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
message) { | ||
return typeof message?._getType === "function"; | ||
@@ -3,0 +5,0 @@ } |
{ | ||
"name": "langsmith", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.", | ||
@@ -55,3 +55,4 @@ "packageManager": "yarn@1.22.19", | ||
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000", | ||
"lint": "eslint 'src/**/*.{ts,tsx}' --quiet --fix", | ||
"lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/", | ||
"lint:fix": "yarn lint --fix", | ||
"format": "prettier --write 'src/**/*.{ts,tsx}'", | ||
@@ -58,0 +59,0 @@ "format:check": "prettier --check 'src/**/*.{ts,tsx}'", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284289
6992